Diagnose Assembly Loading Failures

Majority of the time, you can use fuslogvw.exe to find out why an assembly load failed.

There are times when fusion binding log tells you that the assembly is found successfully, but you still get an FileLoadException.

One of the common case is that one of the unmanaged dlls the assembly depends on cannot be found. After fusion finds the assembly, CLR Loader will try to call LoadLibrary on the assembly to load it. If one of the unmanaged dlls cannot be found, LoadLibrary will fail, and you will receive the FileLoadException.

If that happens, use depends.exe to find out which unmanaged dll is missing. And put it somewhere the OS can find it.

Comments (5)

  1. Stephane Rodriguez says:

    "And put it somewhere the OS can find it."

    Sounds open to all sorts of interpretations. What about scenarios that are not under the developer’s control? For instance a bunch of those scenarios using third parties, some of them managed, some of them unmanaged?

    Where do you draw the line between "simple applications that can live of their own in an isolated folder", and "general purpose applications that may or may not integrate others, rely on shared libraries, use a combination of unmanaged components"? The latter is of course related to all existing projects, today’s cases if you will, that are incrementally moved to .NET.

  2. Daniel Mori says:

    Thankyou Junfeng for your response to my posting on the Whidbey newsgroup, and for this blog posting.

    When i finally reach my development machine, I will look into what you have suggested.

    Regardless if I do find the problem or not…how did you find this potential problem? I’ve scoured the net for this, and found no answer. It worries me somewhat, that the fileloadexception information I was provided, was so vague. How would I go debugging something like this in the future? Or is it just something you must remember?

    Perhaps providing diagnostics information for CLR assembly loading is just simply lacking 🙁

  3. Stephane,

    Your question is an excellent one. But it is way out of contect for this post:). And it is a huge problem, and need a solid design and coordination. I am not sure I can satisfy you from a high level point of view in my blog. But if you have specific problems, bring it to me. I will be happy to discuss it.


    I work in Fusion team. I definitely see more than you see. Personally I have debugged the same problem many times. I probably should have this in my blog long time ago.

    I will talk to CLR Loader team to see if they can do somethng about this. But in general fusion binding log is your best friend to diagnose assembly loading failures.

  4. Stephane Rodriguez says:

    "But it is way out of contect for this post".

    I wonder how assembly loading issues can be out of context of his post, and this weblog. The problem is dealing with this, not in a pure .NET world, where 100% assemblies are under control and fully managed.

    A kind of POC I’d like to hear more about is how .NET apps integrate existing unmanaged apps, especially with respect to assembly loading. For instance, you want to write a Lotus Notes plugin in .NET.

  5. Stephane,

    When I say "out of context", I mean this post is about to help you diagnose assembly loading failures. We cannot dictate how an application developer/administrator deploys bits, though we do have our probing rules. Ultimately it is the application developer/administrator’s responsibility to make sure the assembly can be discovered and loaded by CLR.

    That said, I am very interested in knowing your scenario, and how can we help you to solve your problem.

    Plugin itself is a huge issue and needs very careful design.

Skip to main content