Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

.net - Can't find PInvoke DLL error in Windows Mobile

I am having a lot of trouble getting a basic scenario to work on windows mobile 5.0 emulator. I have a winforms app that eventually calls into native code. Deployment works fine and all the native DLLs are copied in the same folder as the winforms .exe. I also verified this is the case with Remote File Viewer tool.

However when I launch my app, it always fails with "Can't find PInvoke dll -- System.MissingMethodException" error (when the time comes to call into native code, the DllImport attribute is rendered useless). I know that the native dll is found in the same folder as the executable. What more should I do?

I am using VS 2008.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To extend Jared's answer, four more common reasons to get a MissingMethodException while P/Invoking in the CF:

  1. You are missing dependencies of the native library you are calling into.
  2. The native assmebly was compiled for the wrong subsystem (i.e. desktop, not CE)
  3. The native assembly was compiled for the wrong processor (i.e. x86 and not ARM)
  4. You don't have enough virtual memory for the DLL to load.

Have you verified the DLL entry points are undecorated with something like dumpbin?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...