14
votes

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.

3

3 Answers

19
votes

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.

7
votes

I agree. The problem is that the assembly version numbers did not change.

When transitioning to .NET 3.5 SP1 I made sure that developers were not using SP1-specific APIs by ensuring the build server did not have the SP installed (ie. the build server framework version matched the target machine framework version). Then, once we were ready, SP1 was installed on the build server. A similar approach could have saved you from the pain.

4
votes

The same happended to me with 1.1 and 1.1 SP1 a long time ago... I guess there's not a good solution since the assemblies have the same version, you can try to validate it by hand reading the .net installed version or just install the last service packs in all your dev and production machines.