asp.net - 找不到类型或命名空间名称 'ProfileCommon'(在服务器中编译器生成的代码中)

标签 asp.net asp.net-mvc asp.net-mvc-4 profile

我知道以前有人问过这个问题,但没有一个对我有用,而且我的有点不同。

我的 MVC 4 项目在本地运行,但在服务器中无法运行,并出现以下错误:

Compiler Error Message: CS0246: The type or namespace name 'ProfileCommon' could not be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 194:        }
Line 195:        
Line 196:        protected ProfileCommon Profile {
Line 197:            get {
Line 198:                return ((ProfileCommon)(this.Context.Profile));

Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\e3c4a897\ff4f4317\App_Web_pageheader.ascx.cdcab7d2.rpk2croq.0.cs    Line: 196 

我编写了一个自定义的 ProfileProvider 并配置了项目以使用它:

<profile enabled="true" defaultProvider="sql">
  <providers>
    <clear />
    <add name="sql" type="BusinessLogic.ProfileProvider" connectionStringName="c" applicationName="/" />
  </providers>
</profile>

我使用 ProfileBase 类来访问用户配置文件,而不是 ProfileCommon。上述错误出现在编译器生成的文件中。为什么asp.net生成无法编译的代码?以及为什么它在本地工作?

我在本地安装了 .Net Framework 4.5.1 但在服务器中安装的是 4.5 。与问题有关吗?

最佳答案

当我们从网站项目转移到 Web 应用程序项目时,我的部署中也发生了同样的事情(尽管使用的是带有 WebAPI 服务的 WebForm)。

我们案例中的解决方案是从服务器上的部署文件夹中删除 PrecompiledApp.config,然后重新启动 IIS。

关于asp.net - 找不到类型或命名空间名称 'ProfileCommon'(在服务器中编译器生成的代码中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25622589/

相关文章:

c# - 在 Gridview 中选择行+1?

asp.net - mvc 停止某个字段的客户端验证?

c# - 当前上下文 mvc 4 中不存在名称 ViewBag

asp.net-mvc-4 - 如何在 ASP.NET MVC 4 中使用 Request.Unvalidated?

asp.net - 验证文本框可接受 3 到 1440 之间的整数或 "Default"字

asp.net - ASP.NET web 服务的大型静态数据?

c# - 如何隐藏或显示 Asp :Content using a Session in If statement

c# - 如何手动将带有列表的 View 模型映射到 dto

c# - 在 MVC 中加载页面时是否可以显示验证错误 - 4(使用模型验证)

javascript - MVC 4 应用程序的 Jquery Carousel 问题