问题
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