开发者

A procedure imported by {myassembly} could not be loaded

when running a prorgam, it seems that I am missing a library, when I launch the output of my project I get an exception at startup.

A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
An unhandled exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll

Additional information: A procedure imported by 'my assembly, Version=xx.1.1.0, Culture=neutral, PublicKeyToken=7292581204d9e04a' could not be loaded.

'ScriptX.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', No symbols loaded.

My question is: how can I determine which library is missing because, at this point, I cannot see the values passed to:

mscorlib.开发者_高级运维dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x3a bytes    


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:

A procedure imported by {myassembly} could not be loaded

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

A procedure imported by {myassembly} could not be loaded

(3) Run the app from a debugger - or attach before the load error. 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.


In some cases when using COM, you might just need to unregister and reregister the dll with RegAsm.exe. That is what fixed this issue for me last week, things had gotten out of sync.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜