混合模式程序集是针对“V2.050727”版本生成的,在没有配置信息情况下,无发在4.0运行时架子程序集。-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

混合模式程序集是针对“V2.050727”版本生成的,在没有配置信息情况下,无发在4.0运行时架子程序集。

简介:

  混合模式程序集是针对“V2.050727”版本生成的,在没有配置信息情况下,无法子啊4.0运行时架子程序集。

我的做法是在文件中加如app.config,加入:

 <startup useLegacyV2RuntimeActivationPolicy="true"> 
            <supportedRuntime version="v4.0" />    
  </startup>

 参考原文:

Mixed mode assembly is built against version 'v2.0.50727' error using .NET 4 Development Web Server

If your application has a dependency on an assembly built in .NET 2 you will see the error below if you try to run your application when it has been built in.NET 4.

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

This can be important in VS2010 testing, as test projects must be built as .NET 4, there is no option to build with an older runtime. I suffered this problem when trying to do some development where I hosted a webpart that make calls into SharePoint (that was faked out with Typemock Isolator) inside a ASP.NET 4.0 test harness

The answer to this problem is well documented, you need to add the useLegacyV2RuntimeActivationPolicy attribute to a .CONFIG file, but which one? It is not the web.config file you might suspect, but the C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.exe.config file. The revised config file should read as follows (new bits in red)


  1. <?xml version="1.0" encoding="utf-8" ?>   
  2. <configuration>   
  3.   <startup useLegacyV2RuntimeActivationPolicy="true">   
  4.             <supportedRuntime version="v4.0" />      
  5.   </startup>   
  6.  
  7.   <runtime>   
  8.     <generatePublisherEvidence enabled="false" />   
  9.   </runtime>   
  10. </configuration> 

Note: Don’t add the following <supportedRuntime version="v2.0.50727" />  this cause the web server to crash on start-up.

 

 




 本文转自 破狼 51CTO博客,原文链接:http://blog.51cto.com/whitewolfblog/835113,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章
最新文章
相关文章