便携式类库MVC 4 /使用Visual Studio 2012 RC剃刀? [英] Portable Class Library in MVC 4 / Razor with Visual Studio 2012 RC?

查看:242
本文介绍了便携式类库MVC 4 /使用Visual Studio 2012 RC剃刀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于使用Visual Studio 2012 RC使用工作时,出类的便携式类库,我们得到一个HttpCompileException。剃刀视图中

since working with Visual Studio 2012 RC we get an HttpCompileException when using a class out of an portable class library (.net 4.5 & metro profile) within a razor view.

例外:(德语译成英语翻译谷歌,不好意思)

Exception: (german to english translated on google, sorry)

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和放大器;地铁轮廓)

    • 公共类用户{...}


    • 是手提类库

    • 剃刀查看

      • @model用户

      由于的Visual Studio 2012 RC添加引用System.Runtime是不可能的了。

      Since Visual Studio 2012 RC adding reference "System.Runtime" is not possible any more.

      推荐答案

      在浏览\\ Web.config文件,添加以下code下的<&的System.Web GT; 部分:

      In the Views\Web.config file, add the following code under the <system.web> section:

      <compilation debug="true" targetFramework="4.5">
          <assemblies>
              <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          </assemblies>
      </compilation>
      

      有一堆其他的组件可能还需要参考,具体取决于您的便携式code在使用什么类型。您可以添加每一个你遇到错误,或添加组件的完整列表C:\\ Program Files文件(x86)的\\参考大会\\微软\\框架\\ .NETFramework \\ V4.5 \\外立面

      There are a bunch of other assemblies you may also need to reference, depending on what types your portable code is using. You can either add each one as you encounter the error, or add the full list of assemblies in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades.

      这篇关于便携式类库MVC 4 /使用Visual Studio 2012 RC剃刀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆