Project reference work-around .net 4.5 and .net 3.5

我与影子孤独终老i 提交于 2019-11-27 06:32:17

问题


In continue for this thread:
Mixing .NET 3.5 with 4/4.5 assemblies in the same solution/project

I found a workaround:
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/36b1a209-55d5-4323-91dc-0919ba2e1d03/

What it basically do, get my solution compile and determine each project under what CLR to run.
Does anyone see disadvantage to this ?
It builds the projects, on my 3rd party api that must run on .net 3.5, i explicity write on its App.config to run with CLR 2.0 and not 4.0

 <startup>
 <supportedRuntime version="v2.0.50727"/>
 <!--<supportedRuntime version="v4.0"/>-->
 </startup>

EDIT:
My main application is using .net 4.5 and C# 5 features. My 3rd party API is running on a child process (i start from main) and that process will connect to API that must be on 3.5 and CLR2. So i explicity define there to run as CLR2..


回答1:


Your configuration file will load .NET 2.0 runtime and it would fail at some point loading .NET4.5 components. You really want your app to run in .NET4.5 runtime and be able to load 3.5 components. You should try following config file.

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
    </startup>
</configuration>


来源:https://stackoverflow.com/questions/15549011/project-reference-work-around-net-4-5-and-net-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!