BPe*_*ter 40 c# asp.net razor portable-class-library .net-4.5
因为使用Visual Studio 2012 RC,我们在剃刀视图中使用可移植类库(.net 4.5和metro profile)中的类时会得到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)
...
Run Code Online (Sandbox Code Playgroud)
解决方案结构
由于Visual Studio 2012 RC不再可能添加引用"System.Runtime".
Dan*_*ted 60
在Views\Web.config文件中,在以下<system.web>部分下添加以下代码:
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
Run Code Online (Sandbox Code Playgroud)
根据您的可移植代码使用的类型,您可能还需要引用许多其他程序集.您可以在遇到错误时添加每个,也可以添加完整的程序集列表C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades.
| 归档时间: |
|
| 查看次数: |
5981 次 |
| 最近记录: |