简体   繁体   English

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

[英]The type or namespace name 'ProfileCommon' could not be found (in compiler generated code in server)

I know it has been asked before, but none worked for me and mine is a little bit different. 我知道它之前已被问过,但没有一个对我有效,而我的有点不同。

My MVC 4 project works locally but in server it fails to run with this error: 我的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 

I have written a custom ProfileProvider and configured the project to use it: 我编写了一个自定义ProfileProvider并配置项目以使用它:

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

I use ProfileBase class to access user profile not ProfileCommon . 我使用ProfileBase类来访问用户配置文件而不是ProfileCommon The error above is in a compiler generated file. 上面的错误是在编译器生成的文件中。 why asp.net generates a code that it can't compile? 为什么asp.net生成一个无法编译的代码? and why it's working locally? 为什么它在本地工作?

I have .Net Framework 4.5.1 installed locally but in server it's 4.5 . 我在本地安装了.Net Framework 4.5.1,但在服务器中它是4.5。 is it related to the problem? 它与问题有关吗?

The same thing occurred for me (although with WebForms with WebAPI services) in our deployment when we moved from a Web Site Project to a Web Application Project. 当我们从Web站点项目迁移到Web应用程序项目时,我的部署中发生了同样的事情(尽管WebForms使用WebAPI服务)。

The solution in our case was to delete PrecompiledApp.config out of the deployed folder on the server, and restart IIS. 我们的解决方案是从服务器上的已部署文件夹中删除PrecompiledApp.config,然后重新启动IIS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM