Can exe and assembly work on different versions of the .NET framework?

It might be a dumb question, but here goes ... I have a .NET exe that uses a different .NET assembly. If exe is targeting .NET 4.0 and the target of the .NET 3.5 build is when I run exe, is the build actually running on the .NET 4.0 platform? I suspect this is so. Then my question is, is it possible to run exe on platform 4.0, but use an assembly that works based on 3.5?

+4
source share
2 answers

No, It is Immpossible. The core classes have been changed in .NET 4.0, for example System.String. Your .NET 3.5 build will say that it is dependent on mscorlib v2.0.0.0. But the CLR will reassign this, and it will really get build version 4.0.0.0. Therefore, each assembly in the process is consistent with what the string object looks like. Very important, of course :)

.NET 4.0 supports simultaneous CLR versioning on the process side; a process can contain more than one CLR version. But this will not happen in your case, it is intended to solve the problem when an unmanaged process loads .NET code. Like a COM server. It works in isolation, not knowing that any other .NET code is present in this process. So can afford another version of the CLR. Nothing like your case.

.NET 4.0 3.5 , 3.5 . , Microsoft 4.0 , . . , SO .

+5

.Net 4 .Net 2 dll (, .Net 2 ). , .

0

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


All Articles