A procedure imported by {myassembly} could not be loaded

余生长醉 提交于 2019-11-28 09:01:40

There is in fact a built in mechanism for just these diagnostics.

(1) In your project properties/Debug, make sure 'Enable native code debugging' is checked:

(2) Raise the show-loader-snaps flag - it is a registry key in the IFEO, and is accessible via the 'GlobalFlags' GUI:

(3) Run the app and inspect the (very) verbose output pane. You can mostly skip to the end or look for 'ERROR'.

More details here.

Are you doing any dllimport? - this looks like an issue with an unmanaged dll not being found?

First thing is to ensure that any unmanaged dll's or exe's that you are calling into (via dllimport) are deployed into the same folder as the .Net exe that you are building

If the source of the calling assembly is not available you could try using reflector on that assembly to search for dllimport statements

Other than that you might want to enable the fustion log viewer to trace assembly load issues - see this blog post and msdn page for more details

Implement a handler for the AppDomain.AssemblyResolve event. It tells you which assembly it is looking for with ResolveEventArgs.Name. If this is just an effort to troubleshoot this particular assembly then use Fuslogvw.exe. If the hangup is an unmanaged assembly then DependencyWalker's Profile option can show you what LoadLibrary() call is failing. SysInternals' ProcMon will work too but is a lot noisier.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!