Skip to content

Instantly share code, notes, and snippets.

@congyiwu
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save congyiwu/c0a29e2146f605eaf5fe to your computer and use it in GitHub Desktop.
Save congyiwu/c0a29e2146f605eaf5fe to your computer and use it in GitHub Desktop.
Debugging assembly and type load errors

####If you get an error like:

Could not load type '<SomeType>' from assembly '<SomeAssembly>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234567890abcdef'.
<followed by some stack trace>

Then ask yourself the following questions:

  1. Where is the assembly for the missing type being loaded from? Use the Modules window in the VS debugger.
  2. Was this the right location?
  3. Is the right version of the assembly in that location?
  4. If so, should this version of the actually assembly have that type?

####If you get an error like:

Could not load file or assembly '<SomeAssembly>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
<followed by some stack trace>

Then ask yourself the following questions:

  1. Where should the assembly be loaded from?
  2. Does it exist there?
  3. Is this assembly strongly referenced? If so, does the assembly you found have correct AssemblyVersion?
  4. Where is the process actually looking for the assembly?
    • Use fuslogvw to diagnose issues related to with .NET's standard assembly resolution rules.
    • Debug any custom handlers for AppDomain.AssemblyResolve in the current AppDomain.

####Do not rule out the possibility...

...that there is something wrong with the rest of the stack trace. If necessary, also ask yourself the following questions for each line of the stack trace:

  1. Where is the assembly for the current line of code being loaded from? Use the Modules window in the VS debugger.
  2. Was this the right location?
  3. Is the right version of the assembly in that location?
  4. Is this line of code actually correct? Should it actually be loading the type or assembly that is missing?

####BTW: You may need to attach a debugger to answer the questions above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment