8

I have written c# console app. .NET Framework is by default set to version 4.5. I want to know if there is a way, to test app with older versions of .NET framework or test, which version of framework app actually needs to run( without regarding targettype framework).

9
  • 2
    change the target framework in the project, see if it still compiles? Commented Jul 14, 2014 at 10:32
  • It depends on the code you have used. If you have used 4.5 libs then you will need v4.5. Commented Jul 14, 2014 at 10:35
  • @Lee well, even that isn't strictly true; a range of Microsoft.Bcl packages are available that add later BCL features into earlier frameworks; a lot of new compiler features that depend on those features will also then work against the earlier frameworks. Going back even further, there are things like LINQBridge which adds some 3.5 features into 2.0. Commented Jul 14, 2014 at 10:37
  • @JamesS "...and runs, and behaves the same" ;p Commented Jul 14, 2014 at 10:39
  • Is there a library with methods which are now in system.linq? because i'm only using system.linq, which is in 3.5 or later ... Commented Jul 14, 2014 at 10:39

2 Answers 2

2

You can add some entries to your app.config file to target a particular version of the framework, to override the version that it was built with. Obviously you still need to test that it works with these versions but this allows you to run on different versions of the framework:

<configuration>
  <!-- this is used if they only have net 4 installed-->
  <!--
  <runtime>
    <NetFx40_LegacySecurityPolicy enabled="true"/>
  </runtime>
  -->
  <startup>
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0.30319"/>
  </startup>
</configuration>
Sign up to request clarification or add additional context in comments.

1 Comment

+1, perhaps you could add a remark about, or hint at, the <requiredRuntime> element as well?
0

My problem was regarding the System.Linq library, which isn't supported in .NET framework 2.0. As you can read in comments, I fixed this with using LINQBridge from nuGet. The other problem was, that framework 2.0 does not contain public method Dispose for HashAlgorithm. I solved this with using Clear method. All the other errors were fixed with reinstalling all nuget packages.

1 Comment

Don't you know that Microsoft no longer supports .NET 2.0 unless you have .NET 3.5 SP1 applied? If you know that, you should be able to stop right now, and focus on .NET 3.5+. Don't waste any more time on that. blogs.technet.com/b/lifecycle/archive/2010/04/30/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.