Problem using 'useLegacyV2RuntimeActivationPolicy & supportedRuntime in application

I changed several .config files of different applications:

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

When I did this for devenv.exe.config (VS 2005 - I do not ask :)) everything worked fine - most of Visual Studio used .NET 2.0, but I was able to use assembly targeting for .NET 4.0.

I tried to do the same for a custom .exe, which turned out to be based on MS CAB (slightly modified) and has a hybrid mix of WPF and WinForms content. As soon as I changed this app app app file, I started getting this exception, sometime during application launch:

A different context was found in the Undo operation than what was applied in the corresponding Set operation. A possible reason is that the context was set in the stream and was not canceled (canceled). System.InvalidOperationException: The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. A possible reason is that the context was set in the stream and was not canceled (canceled).

There is a big long stack trace that doesn't show anything in my application code (just a bunch of MS builders).

If I change the application's .config file to this:

<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>

ieI removes the supported Runtime element, then the application does not throw this exception. But when I go to a point in my code where I try to load my .NET 4 assembly if this fails:

System.BadImageFormatException: '' . , , , .

, .

:

1) , System.InvalidOperationException , Runtime, .NET 4 , ?

2) " , / , ", .NET 3.5 SP1 (#), .NET. 4 () .NET 4 ? - .NET 4, , /.

, !

+3
1

, VS2005, , " Visual Studio .NET 2.0, .NET. 4.0". config v4. , , , , . (, , , , VS2005 v4.)

, , - . , . ?

... . CLR SxS proc COM-, , , COM-, . , , v4 - , .

, . SxS .

+4

Source: https://habr.com/ru/post/1738583/


All Articles