views:

54

answers:

3

I have a .NET 4.0 class libary, which only uses .Net 2.0 features. To make this library more compatible with Mono, I'm considering changing the Target Framework to 2.0 instead of 4.0 Client Profile.

But the question is: Does changing the Target Framework to an older version, make the library run slower (hurt performance). The GUI of the application will still target 4.0, so all Windows PC's running the application will have the 4.0 framework installed. Will my 2.0 library be executed by the 4.0 JIT compiler (performance should be the same) or by the older 2.0 JIT (performance could be slower)?

+1  A: 

If you target the old framework, then the code will execute on the old CLR. So performance will be that of the old CLR and potentially slower but you'd have to profile to see if it's an issue.

Preet Sangha
you missed "The GUI of the application will still target 4.0"
Ian Ringrose
+1  A: 

No, as app still targets version 4 of the framework (as you said "GUI of the application will still target 4") then all the code will use the V4 jit and therefore run at the V4 speed even if a given dll target V2 of the framework.

Ian Ringrose
A: 

The .NET Framework 4 is backward-compatible with apps built with versions 1.1, 2.0, 3.0, and 3.5.

As far as performance goes, I don't think a noticeable difference will be apparent. You should be more concerned about the different framework versions breaking compatibility due to obsolete functionality.

See here for detailed compatibility information

Wez