views:

67

answers:

2

I am writing a code base in C#, and have had issues with test PC's not having the correct service pack of .NET 3.5 installed to run the code (the same issue as occuring here: http://stackoverflow.com/questions/475319/exception-is-occuring-only-on-my-machine-method-not-found-waithandle-waitonein). I am wondering if there is a static code analysis tools that I can run across my code that will tell me the minimum version of .NET required by each of the individual modules (or by the assembly).

Thanks.

+3  A: 

Project properties->Application->Target framework.

Alex Reitbort
This is more about checking which version a piece of code requires with regards to service packs, which cannot be targeted to, but nevertheless are not statically checked for compatibility at compile time, but rather fail at runtime with a MissingMethodException...
Pete
+1  A: 

I am not aware of any static analysis tool, but here's what I've found, based on MSDN docs and a few blog posts:

  • VS 2008 / VS 2008 SP1+ / VS 2010 ".NET Framework 2.0" - .NET 2.0 RTM
  • VS 2008 / VS 2008 SP1+ / VS 2010 ".NET Framework 3.0" - .NET 3.0 RTM
  • VS 2008 ".NET Framework 3.5" - .NET 3.5 RTM
  • VS 2008 SP1+ ".NET Framework 3.5" with a reference to System.Data.Entity.dll or using ClickOnce - .NET 3.5 SP1
  • VS 2008 SP1+ ".NET Framework 3.5" without a reference to System.Data.Entity.dll and not using ClickOnce - .NET 3.5 RTM
  • VS 2010 ".NET Framework 3.5" - .NET 3.5 SP1
  • VS 2008 SP1+ ".NET Framework Client Profile" - .NET 3.5 SP1 (client)
  • VS 2010 ".NET Framework 3.5 Client Profile" - .NET 3.5 SP1 (client)
  • VS 2010 ".NET Framework 4.0" - .NET 4.0 RTM
  • VS 2010 ".NET Framework 4.0 Client Profile" - .NET 4.0 RTM (client)

Notes:

  • VS 2008 shipped with .NET 3.5 RTM; VS 2008 SP1 shipped with .NET 3.5 SP1; VS 2010 shipped with .NET 4.0 RTM.
  • VS 2010 is unable to target earlier versions unless they are installed seperately.
  • The client profile was introduced in .NET 3.5 SP1
  • VS 2010 is the first version with extensible multitargeting (so - in theory - it will be able to target future .NET versions without a VS update).

I believe .NET 3.5 SP1 is the only service pack that added significant functionality, so it's the only one that will cause MissingMethodException problems. For example, this would mean that 3.0 RTM, 3.0 SP1, and 3.0 SP2 have the same public API. I haven't found explicit confirmation of this, but the "what's new in .NET" documentation only covers 2.0/3.5/3.5SP1/4.0, so this is a logical conclusion.

VS 2008 SP1 has some weird rules regarding ".NET Framework 3.5" (trying to target SP1 only if it's actually used), but VS2010 just supports targeting .NET 3.5 SP1.

Sources:

Stephen Cleary