.net – System.MissingMethodException – 3.5 SP1 versioning hell

exceptionnet

After deploying an ASP.net webservice to my production server i got this exception:

System.MissingMethodException

Method not found: 'Boolean
System.Threading.WaitHandle.WaitOne(Int32)'

The MSDN documentation states:

Version Information
.NET Framework
Supported in: 3.5 SP1, 3.0 SP2, 2.0 SP2

so the reason of this error is that my server was not updated to the latest service pack.

The question is:

Why does the code start? IMO if the target framework version is different the app should not start at all.

How can I assure that my code can run on the target machine framework version before JIT?

This is crazy. I think Microsoft should take versioning issues more seriously.

Best Answer

Though the method:

Boolean System.Threading.WaitHandle.WaitOne(Int32)

doesn't exist, the method:

Boolean System.Threading.WaitHandle.WaitOne(Int32, bool)

does exist.

Looking with the reflector - the WaitOne(Int32) calls WaitOne(Int32,bool) with false as the boolean value. So simply use the second signature, providing false as the boolean value, and you should be just fine.