Running .NET 3.5 built Mixed mode assemblies in .NET 4 using app config requires Framework 3.5 as well

戏子无情 提交于 2020-01-11 09:28:11

问题


This is similar to already created thread here: Mixed mode assembly in .NET 4

Using the app config, I was able to force the assemblies to run on .NET 4. On an XP Machine, I installed just the .NET 4 (without .NET 3.5 or 2.0) and tried to run the built application. It fails to load the mixed mode assembly built in 3.5 framework in .NET 4 without the .NET 3.5 framework on the machine.

Why should it depend on .NET 3.5 when I am forcing the application to run on .NET 4 using App config?


回答1:


You're experiencing that problem because .NET 3.5 uses the Common Language Runtime (CLR) version2 and .NET 4.0 runs on CLR v4. Therefore if your assembly was built in .NET 3.5, it will only run on a computer that has CLR v2.

Long story short. Compile your .NET 3.5 assembly as a .NET 4 assembly, otherwise install .NET 3.5 on the target computer as well.


You can see this site for more information:

  • .NET Framework Versions and Dependencies



回答2:


The reason is, that the way how it binds to mixed mode assemblies. Make sure you use the useLegacyV2RuntimeActivationPolicy="true" option in the startup-configuration of you app.config file (which I assume looks similar to the following):

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0.30319" />
  <supportedRuntime version="v2.0.50727" />
</startup>

See also: What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?



来源:https://stackoverflow.com/questions/3836704/running-net-3-5-built-mixed-mode-assemblies-in-net-4-using-app-config-requires

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