Link to home
Start Free TrialLog in
Avatar of Lawrence Avery
Lawrence AveryFlag for United States of America

asked on

.NET Target Framework Version

When adding a reference (Authentication.dll) to my project I received the following message:

The target Framework version for the project Authentication is higher than the current Project Target Framework version. Would you like to add this reference to your project anyway?

So what should I answer? The Authentiction.dll was created under .NET 3.5 and the current project target framework version is 2.0.

That brings me to a second question. When running an application, how does the application pick the .NET Framework Version to use for the overall application?
Avatar of Wim_Bl
Wim_Bl
Flag of Belgium image

Hi,

in fact it is possible to mix different versions in 1 project, although I would try to upgrade the main project to the same version as the referenced dll, just to clear things up. A nice article about this situation can be found at http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx

Hope this helps you out in the right direction.


Best regards
Avatar of Lawrence Avery

ASKER

In response, I think I will upgrade main project to the same version of the reference dll. So bottom line you are saying  there is a way an application with exe and its dlls can reference different versions of .NET Framework at the same time. In other words, my main project say uses .NET 2.0 and the dll that is referenced by my main project uses the 3.5 .NET Framework?
That's right, since .Net 2.0 and .Net 3.5 share the same CLR mainly. If suspect that you will get into trouble if you want tot reference 4.0 dll's, but I believe that is not the case here. Some further reading can be found at http://abdullin.com/journal/2008/12/23/how-to-use-net-35-features-and-c-30-syntax-in-net-20.html

Best regards
So your answer above really relies on version of CLR. That CLR can work with two different versions of .NET FRAMEWORK at the same time?????

Special Note on the contrary with VS2010 and higher:See link below VS2010 indicating VS2010 does not allow that anymore:
http://stackoverflow.com/questions/3298577/visual-studio-2010-reference-assemblies-targeting-higher-framework-version.

So in the VS 2010  .NET world when someone hands you a reference dll to use, you need to ensure the main project is equal or higher in version? That is the basic rule of thumb right?
That's right, it is backward compatible. Earlier on, it only looked like that, as is stated somewhat further in the article:

The .NET framework version numbering got to be a mess after 2.0. An assembly does not target a .NET framework version, it targets a CLR version. And the CLR version for framework versions 2.0, 3.0, and 3.5 was the same, 2.0.50727
One last comment, Are you saying when the CLR 2.0.50727  runs, it checks out more than one .NET FRAMEWORK  2.0, 3.0, and 3.5  for the dll it needs? Checking the higher version .NET Framework first?
ASKER CERTIFIED SOLUTION
Avatar of Wim_Bl
Wim_Bl
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
n/a