我知道以前有人问过这个问题,但没有一个对我有用,而且我的有点不同。
我的 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/