7

I am debugging an assembly loading problem, so I'm looking through fusion logs. Sometimes they confuse me because they begin with indicating a failure, then in the end they say the assembly loads from where I expect it to be loaded.

What does "The operation failed" followed by "IL assembly loaded from..." really mean? Did it fail to load the assembly, or did it succeed?

*** Assembly Binder Log Entry  (2012-03-16 @ 10:25:14) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program\MyCorp\MyApplication1.2.0.0\MyApplication.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = VIRTUALXP-63912\XPMUser
LOG: DisplayName = MyCorp.MyApplication.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program/MyCorp/MyApplication1.2.0.0/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyApplication.exe
Calling assembly : MyApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image MyCorp.MyApplication.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
WRN: No matching native image found.
LOG: IL assembly loaded from C:\Program\MyCorp\MyApplication1.2.0.0\MyCorp.MyApplication.Core.dll.

I also see this kind of log for an assembly even when the program exits stating can't load file or assembly SomeAssembly or one of its dependencies. The assembly in question is loaded according to a log entry similar to the above.

Would this indicate that a native dependency of the assembly was not found? Do I need to change the log settings to see which native dependency failed, or is there something else I can do?

Anders Forsgren
  • 10,827
  • 4
  • 40
  • 77
  • Is this the whole log? From what I can see there was no failure (since a native image of `MyCorp.MyApplication.Core` was found, a managed version that was found was loaded. – Oded Mar 16 '12 at 09:47
  • This is the log for one particular dll. This dll is a managed dll, and it loads successfully as far as I know. Which is why I wonder what "failed". – Anders Forsgren Mar 16 '12 at 10:02
  • Look for another log entry that shows a binding failure for "one of its dependencies". SysInternals' ProcMon can show you it searching for an unmanaged DLL if that's the cause. Ignore "no matching native image found", that's normal. – Hans Passant Mar 16 '12 at 13:20
  • I can't see any log entry with a suspicious binding failure at all. The application exits with a fileloadexception for someassembly.dll "or one of its dependencies". ProcMon shows no sign of trying to load someassembly.dll at all. – Anders Forsgren Mar 16 '12 at 14:01

1 Answers1

0

I think it's because the CLR makes some attempts searching the dll so it firstly fail and then succeed. You can bind to the assemblyresolve event and have a look on how it works. If I remember it searches first in the GAC then local folder then subfolders...

See documentation here.

Difster
  • 3,264
  • 2
  • 22
  • 32
L.Trabacchin
  • 1,538
  • 1
  • 17
  • 34