在VS 2010中,如果你正在使用Entity Framework,将MVC2项目的.csproj文件中的
<MvcBuildViews>true</MvcBuildViews>
改为该值会导致错误。具体地,在调试时构建视图,同时保证项目能够编译是我的需求。<MvcBuildViews>true</MvcBuildViews>
改为该值会导致错误。具体地,在调试时构建视图,同时保证项目能够编译是我的需求。您可以通过在web.config文件中添加以下元素来解决此MVC编译问题:
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
这将告诉编译器在哪里找到缺失的类型。
或者你可以移除构建提供程序。
<system.web>
<compilation debug="true" targetFramework="4.0">
<buildProviders>
<remove extension=".edmx"/>
</buildProviders>
</compilation>
</system.web>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
</configuration>
当我设置MvcBuildViews="true"
时,我遇到了类似的错误,这与构建临时文件找到多个web.config有关,而且根本不喜欢它。
这是完全不同的错误,但我有一个隐秘的怀疑,它们可能有关联...
解决方案基本上让您更改构建的输出路径...因此,您需要将<BaseIntermediateOutputPath>
添加到您的网站的csproj文件中。
例如:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...BLAH...
<BaseIntermediateOutputPath>..\TempBuildOutput</BaseIntermediateOutputPath>
</PropertyGroup>
...A WHOLE LOTTA BLAH...
</Project>
祝一切顺利,
查尔斯
声望不足,无法添加评论。想提醒一下,您需要将'System.Data.Entity.Design'程序集引用添加到根Web.config中。我不小心尝试将其添加到我的Views目录中的Web.config中。要注意这个陷阱。
<system.web><compilation><assemblies>
中 - 为了避免其他人费力去弄明白。参考 https://dev59.com/D2ox5IYBdhLWcg3wDgXR#10078384 - Tim Abell