C # .Net framework versioning

What could be the problems if I create a solution where all projects are under targetFrameworkVersion = 2.0, but with targetFrameworkVersion = 3.5 and

  • None of the 3.5 features are used.
  • Some of the functions of 3.5 are used, but classes that invoke 3.5 code are never instantiated.
  • Some of the 3.5 functions are used in some classes, instanciated classes, but the code in 3.5 was never called
  • code 3.5 is called
+4
source share
2 answers

It depends on what you mean by "functions." There are compilation-time functions such as the var keyword and lambda expressions, as well as runtime functions such as LINQ or WCF, which require libraries in the .NET 3.x runtime.

I assume that you are using Visual Studio 2008, which will handle all compile-time functions. If all you use is compile-time functions, then everything will work fine in all cases. I do this quite often in my current project.

If you use runtime functions, I believe that this is how it will shake out:

  • Everything will work.
  • I think this will work too.
  • It depends on when the static functions are JITted, and if you have the library link code 3.5 in static functions.
  • Probably MissingMethodException when a function is called that contains a library function 3.5.

Instead of worrying about all this, if you plan to use the runtime functions, I just add a key to App.config that 3.5 runtime is required, and it checks the launch and the bomb if it is not there. Then you do not need to define all these permutations, and your application will be more stable.

+1
source

First of all, you need to know that targeting is actually .NET 2.0 SP1 .

How are your projects connected? Do you have projects created in .NET 2.0 that reference a .NET 3.5 project (or vice versa)?

0
source

All Articles