Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any performance implications of a .NET 4 application calling a .NET 2 DLL?

Tags:

c#

.net

winforms

I could not find the answer to this exact question but there are related ones.

We have BIG WinForms application that is compiled to use .NET 4. However, several of the DLL's that we call and all the 3rd party controls are compiled to use .NET 2. Obviously this works but are there any negative performance issues because of this scenario and if everything was using .NET 4 would it be faster.

I am not trying to micro optimize but if I can get a tiny/small boost by just recompiling what I have the source code for I am willing to make the effort if there is a gain.

like image 327
Scott Wylie Avatar asked Nov 16 '11 00:11

Scott Wylie


1 Answers

In theory, there shouldn't be any significant impact on performance.

The compatibility goal for the .Net Framework is that applications and components from previous versions should work smoothly on the .Net Framework 4...

When a .NET 4.0 application loads a .NET 2.0 assembly, it gets loaded into the 4.0 runtime using a compatibility mode feature that helps to prevent breakages:

In-Proc SxS does not solve the compatibility problems faced by library developers. Any libraries directly loaded by an application--either via a direct reference or an Assembly.Load--will continue to load directly into the runtime and AppDomain of the application loading it. This means that if an application is recompiled to run against the .NET Framework 4 runtime and still has dependent assemblies built against .NET 2.0, those dependents will load on the .NET 4 runtime as well. Therefore, we still recommend testing your libraries against all version[s] of the framework you wish to support. This is one of the reasons we have continued to maintain our high level of backward compatibility.

like image 97
James Johnson Avatar answered Sep 28 '22 15:09

James Johnson