Here I will post problems I and my colleagues met and solutions we found.

Wednesday, May 18, 2011

Using .NET 2.0 assembies from .NET 4.0

I was always curious how exactly assemblies compiled for .NET 2.0 are used when you reference from asseblies compiled for .NET 4.0. Somehow, I could not find "an official" answer to this question, and was too lazy to check myself. Thankfully, I have a young collegue who was as curious as I am but not so lazy.

So, here is an experiment.

Exe A,

  • target platform 4.0
Assembly B,
  • target platform 2.0,
  • referenced by exe A.
  • references System.dll, .NET 2.0.

Question, will System.dll 2.0 will be loaded when we run A, or System.dll from 4.0?

The answer - System.dll from 4.0.