views:

130

answers:

4

I'm updating an old mobile device application for better flexibility. I had basically added the ability to configure the address of our SQL server in the case that we want to use our test server as opposed to our production server. I don't think this is causing the problem, but I wanted to state it. I also upgraded the project from a VS 2003 project to a VS 2005 project.

The issue I am having is that when I try to run the program in the VS emulator for Pocket PC, I get an error. It occurs after our "main menu" form loads and the user selects the next form to load. The form is initialized without issue, but when we try to run the .ShowDialog() method, it throws a System.MissingMethodException.

I don't have a lot of experience with the Compact Framework and really have no idea where to start looking for problems. I stepped the debugger through the entire initializing process for the new form and it ran without issue. But, again, when we come to the ShowDialog call, it throws the error.

Any ideas in where to start looking or known issues would be greatly appreciated.

A: 

Start looking in the ShowDialog method itself. The error is slightly misleading - it's not ShowDialog which it can't find, but the JIT compiler is probably trying to compile ShowDialog, and throwing that exception (because ShowDialog is trying to call something it can't find). If ShowDialog is in a different assembly, then there may be something static that can't be initialized, which could similarly cause this - but start out looking in ShowDialog itself.

Because of this, one trick to finding the problem (if it isn't obvisou) is to reduce the code in ShowDialog until you find the line causing the problem. I'd start out commenting ALL the code, to confirm my hypothesis. If you no longer get the exception, try uncommenting about half of the remaining code at a time, etc.

Andy Jacobs
A: 

I'm usually getting MissingMethodException for this reason:

  • I've got at least two files in my project, for instance an .exe file and a .dll file
  • I make changes to the .dll file's source code, and recompile
  • VS says it deploys the new .dll file to the device, but indeed it does not (it keeps the old file)
  • The .exe starts up fine, but when it starts accessing the .dll file the application throws a MissingMethodException, because it can't find the methods in the old dll file.

Fix: Delete the entire application directory from the device and redeploy.

Felix Alcala
A: 

You can get this exception when you try to use a regular WinForm class from a compact project.

Hans Kesting
+1  A: 

I should have added this long ago. The answer ended up being that the incorrect version of .NET was installed on the Mobile Device.

Boerema