Friday, May 14, 2010

MissingMethodException

During acceptance testing you always got the strangest errors logged, most of the time errors you can’t reproduce in your development environment.

A nice one I got this week is the following:

Type : System.MissingMethodException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

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

It turns out that on the customer’s computer, a MissingMethodException is thrown when calling:

bool signal = WaitHandle.WaitOne(0);

The customer assured me they had the.NET Framework 2.0 installed. So how can this  system method not be there?

Turns out, that this overload of the WaitOne method that was introduced in .NET 2.0 SP2.  However it seems that SP2 is not installed by Windows Update and isn’t even available as a separate download. It is only available as part of .NET Framework 3.5 Service Pack 1.

There are two “fixes” for this problem:

  • Supply a boolean as the second argument to WaitOne in all your code.
  • Require .NET 3.5 SP1 to run the application.

As we promised the customer that the .NET 2.0 Framework  is supported, we changed the code.

Who does not like this kind of problems?

No comments: