6

I have an application that runs fine on .Net 2.0 SP2, but fails to run properly on .NET 2.0 RTM. (FYI: It fails when calling a method a managed DLL that is a wrapper for a native DLL for USB programming).

I know you can give supported runtimes in the app.config of a C# .NET application

  <startup>
    <supportedRuntime version="v2.0.5727" />
    <supportedRuntime version="v4.0" />
  </startup>

However, is it also possible to specify a specific Service Pack version?

Thanks!

Edit: I did now find out which method fails between 2.0 and 2.0 SP2. It is WaitHandle.WaitOne(int) which was added in 2.0 SP1.

A tip for everyone else having the problem, the compiler doesn't say anything but if you ngen the executable with the problematic runtime, it does give you the exact error.

E.g.:

Warning: System.MissingMethodException: Method not found: 'Boolean System.Threading.WaitHandle.WaitOne(Int32)'. while resolving 0xa0000e1 - System.Threading.WaitHandle.WaitOne.
11/11/2010 01:54:07 [3620]: Method not found: 'Boolean System.Threading.WaitHandle.WaitOne(Int32)'. while compiling method XXX

Rogier

Rogier
  • 1,170
  • 1
  • 10
  • 21
  • 1
    Check out...http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed – Aaron McIver Nov 09 '10 at 15:27

2 Answers2

1

Great explanation can be found here on why this is not possible. You can locate a SO response here to address your needs.

<supportedRuntime> doesn't actually work that way, because the 3.5 framework uses the 2.0 runtime. You can only specify runtimes that way, not frameworks, and the element only expresses preference, not demand.

Community
  • 1
  • 1
Aaron McIver
  • 24,527
  • 5
  • 59
  • 88
  • OK, seems logical. I have taken care of all the details in my NSIS installer, but some users were copying the files to other PC's... – Rogier Nov 09 '10 at 16:04
0

Try this (for .net 2.0 sp2):

<supportedRuntime version="2.0.50727.1433" />

.NET Framework versions here.

Liviu Mandras
  • 6,540
  • 2
  • 41
  • 65
  • Doesn't work. Quoting: "The string value must match the directory name found under the .NET Framework installation root." – Hans Passant Nov 09 '10 at 16:04
  • Well I did started the post with "Try". I will not delete it so that others can see that this is not a valid option. – Liviu Mandras Nov 09 '10 at 16:06