Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multitargeting in .NET

Having gone through various blogs, I am quite confused about the terminology of "multitargeting" or side by side execution.

  1. Some blogs say that, side by side execution means two versions of CLRs in a process. Some others claims that, its like .net 2.0 and .net 3.0 assembly executing side by side. I am extremely disappointed that I am unsure who is right who is wrong.

  2. I also saw in many blogs like Scott Hanselman's blog etc (Which confuses a lot), that, any feature of .NET 4.5 will not work if the target framework is 4.0. I can agree to it. But I cannot agree or understand the fact that, a feature of 4.0 whose bug is fixed in 4.5, will go hidden if I build it using 4.5 and deploy in 4.0. Here I don't understand the term "hidden" and nobody dare to explain what actually it means. It means runtime error ? It means compile time error? It cant be this. It means inconsistent behavior ? Exception ? If this is the case, I wonder why MS has let this type of flexibility in development in VS. Does it serves ANY purpose ? I understand that, the first case is meaningful, but dont understand or agree with second case.

  3. I also saw in Rick/Scott Hanselman's post that, Major changes means, complete upgrade including CLR. Then, I should see 3.0 as major upgrade but its not as it still uses .NET 2.0 CLR. Then why the naming terminology is 3.0.x.x/3.5.x.x ? Like the case in .NET 4.0.30319.x where CLR is also new, so I agree with this. I am surprised who is correct. Either these folks or MSDN as both contradicts their principles (Like MSDN says the formatting as Major.Minor.Build.Revision, and Hanselman or others say, Major means CLR upgrade and while it is not in .NET 3.0)

Ref: http://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx

http://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx

Any thoughts on above two questions?

like image 301
Jasmine Avatar asked Mar 22 '13 11:03

Jasmine


People also ask

What is TFM in dotnet?

When you target a framework in an app or library, you're specifying the set of APIs that you'd like to make available to the app or library. You specify the target framework in your project file using a target framework moniker (TFM). An app or library can target a version of . NET Standard. .

Can I reference .NET standard from .NET framework?

NET standard, being a specification, is like an interface. Whenever you add a reference to a . NET standard library, as long as the reference meets the specification definition, then the library doesn't care what type it is. Implementation is separate from specification.

What is .NET Framework multi-targeting pack?

A multi-targeting pack, or MT pack, is a set of reference assemblies that corresponds to a particular . NET Framework platform and version.

What is .netcore in C#?

NET Core is used to create server applications that run on Windows, Linux and Mac. It does not currently support creating desktop applications with a user interface. Developers can write applications and libraries in VB.NET, C# and F# in both runtimes.


1 Answers

First of all you have to understand difference between the Multitargetting and Side-by-side execution.

  • Multitargettting is the ability you to compile applications which would be run on the CLR runtime which different from that you are using for the developing the application (.NET 4.0 in case of VS2010 or .NET 4.5 in case of VS 2012). Multitargetting in the VS ensures that your application would not use any types or methods which was introduced in the CLR runtime and Base Class Library (BCL) in the versions which are newer then the version which you are targetted. VS doing so by having copy of the DLL's which are used in the each runtime which could be targetted.
  • Side-by-side execution means that you could have more then one version of CLR runtime installed on you PC. As of CLR 4.0 is no longer correct. You now able to load CLR 4 inside same process together with older runtimes (CLR 1.1 or CLR 2.0). Please read http://msdn.microsoft.com/en-us/magazine/ee819091.aspx (Section "Overview of Behavior") for more details.

Regarding your questions:

  1. Please read link from the MSDN article mentioned above.
  2. Term hidden means that when you will debug application under .NET 4.5 you have versions of BCL with bugfixes which potentially hit you in the back after you deploy to .NET 4.0 since that bug was not fixed yet on that version of BCL. You will have runtime error which you could observe in the way which would depends on the type of bug which you reaching. That could be security issue, logical error in your application or runtime exception. If you want to catch these issues you could always test on the clean PC which has only .NET 4.0 installed.
  3. Both links that you give does not interfer with each other in any way. Scott and MSDN both are correct in the explanation what version of .NET has which version of CLR runtime has installed.
like image 137
codevision Avatar answered Oct 04 '22 22:10

codevision