####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:
- Where is the assembly for the missing type being loaded from? Use the Modules window in the VS debugger.
- Was this the right location?
- Is the right version of the assembly in that location?
- 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:
- Where should the assembly be loaded from?
- Does it exist there?
- Is this assembly strongly referenced? If so, does the assembly you found have correct AssemblyVersion?
- 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:
- Where is the assembly for the current line of code being loaded from? Use the Modules window in the VS debugger.
- Was this the right location?
- Is the right version of the assembly in that location?
- 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.
- Search the code for calls to
Debugger.Launch()
. There may be a magic environment variable/argument that launches the debugger for you. - To attach a debugger to any arbitrary process at startup, see: http://bugslasher.net/2011/03/26/how-to-debug-a-process-as-soon-as-it-starts-with-windbg-or-visual-studio-2010/