自从使用Visual Studio 2012 RC以来,当在Razor视图中使用可移植类库(.net 4.5和Metro配置文件)时,我们会遇到HttpCompileException异常。
异常信息:(已由谷歌翻译自德语至英语,抱歉)
解决方案结构:
异常信息:(已由谷歌翻译自德语至英语,抱歉)
System.Web.HttpCompileException (0x80004005):
c:\Users\user\AppData\Local\Temp\Temporary ASP.NET
Files\root\1995167a\126b7c4d\App_Web_index.cshtml.1fbcdbb1.zaniprm5.0.cs(29):
error CS0012: The type 'System.Object' is not in a referenced assembly is
defined. Add a reference to the Assembly "System.Runtime, Version = 4.0.0.0,
Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" added.
at
System.Web.Compilation.AssemblyBuilder.Compile()
System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
...
解决方案结构:
- 可移植类库(.net 4.5和metro配置文件)
- public class User { ... }
- MVC 4(.net 4.5)
- 引用可移植类库
- Razor视图
- @model User