.NET WPF MissingMethodException when starting a new thread

I have a WPF application with a form that, when launched, calls a special method in a new thread.

Private Sub TestStep1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded Dim oThread As New Thread(AddressOf DisplayNextPicture) oThread.Start() End Sub Private Sub DisplayNextPicture() '' do stuff End Sub 

This works fine on my machine, but on the client, starting a new thread throws a MissingMethodException. I'm not sure why this will happen (and, unfortunately, the client is in a remote location, so I need to debug this by slipping in the trace instructions and trial and error). This is definitely the DisplayNextPicture () method, which was not found, as I was able to determine through tracing.

The only thing I can think of is that it is related to frame level security. Are there any restrictions on starting new threads from a WPF application?

I cannot catch this exception through Application.DispatcherUnhandledException, so I cannot get any exception data or stack trace. The client receives a .NET runtime exception dialog with the following information, and this is the only way to find out the type of exception:

EventType: clr20r3 P1: testapp.exe P2: 1.0.0.0 P3: 49fa2234 P4: mscorlib P5: 2.0.0.0 P6: 471ebc5b P7: 1295 P8: 14
P9: system.missingmethodexception

Please, help:)

+6
multithreading exception wpf
source share
6 answers

I just ran into this problem while trying to start a Windows service (which I wrote). The service will work fine in my test environment, but not on another machine.

The problem was that the Framework 3.5 version was running in a difficult machine, while my development machine was running 3.5 with Service Pack 1 (SP1). Updating the machine to version SP1 fixed the problem.

Hope this alleviates the pain a little.

+2
source share

I used VS2008, .Net 3.5 and had a similar problem starting a thread for a service. Troubleshooting upgrade to .Net 3.5 SP1. Thanks for helping the guys.

+3
source share

I got a System.MissingMethodException exception when testing my .NET 3.5-oriented application on Windows XP SP3. I finished installing Visual Studio 2008 Express to try compiling the application from the start. Only then did the compiler give me the corresponding error, it turned out that the WaitOne method in AutoResetEvent has only a signature with two parameters, so I had to rewrite:

reset.WaitOne(1000);

to

reset.WaitOne(1000, true);

I assume that Microsoft forgot to add the first overload to Windows XP.NET 3.5. Since it works and exists, on Windows 7. Go to the figure.

+3
source share

FWIW, I had a P9 system.missingmethodexception error that crashed a simple application on some machines, but not on others. I traced it to the line ".WaitOne (2000)" that was running inside the thread. It never causes a problem with my car, but it surely crashed into these other cars, EVEN THAT THE CODE WAS NOT EXECUTED! The thread did not even reach this line. The crash occurred when the program started, which was very unpleasant. I even had a "try..catch" around the problematic line of code, and that didn't help. I stopped using AutoResetEvent and used the variable and " while( ! signaled ) { Thread.sleep(20); } , which was awkward, but it worked ...

+2
source share

MissingMethodException thrown by JITer (compiler only in time). Jitter compiles assembly language code one method at a time. There is some method inside the delegate method (DisplayNextPicture) that calls a method that does not exist in the libraries on the target machine, and I assume that an older version of .net is working. Because trembling cannot find the way that it explodes.

I came across this several times when you built on a computer with VS 2008 and 3.5 SP1, and then tried to run on a computer with only 3.0 installed. Sometimes Microsoft adds a method to libraries and does not update their major or minor versions. Often this is done in one of the .net framework service packs.

Go through the code in the delegate method and look at MSDN for any suspicious methods and double-check "Version Information" to see which framework versions are supported for the method.

You can also just upgrade your client to the latest version.

+1
source share

I had the same problem. I called the overload of the Dispatcher.Invoke method, which was not in the .Net executable version. I found a helpful comment on MSDN about a method that helped me, although my problem was a bit different.

http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.invoke.aspx

If you use the Invoke method, try using the overload with the DispatcherPriority parameter as the first argument.

+1
source share

All Articles