Debugging an InvalidCastException

First, obviously, find the two types for which the cast failed and verify that they are the same type or otherwise castable. Next, if the type was just deserialized, also verify that its assembly successfully loaded in the target appdomain. If everything seems fine, check to see if the assemblies for those two types are loaded from different locations and…


Debugging a MissingMethodException, MissingFieldException, TypeLoadException

Say you’ve just installed some assemblies from a third party and now you’re seeing a MissingMethodException, MissingFieldException, or TypeLoadException (during the run of an application using those assemblies). Below are the common causes. Loading failuresFirst, check for assembly binding failures by getting the Fusion log. Look for the assembly containing that method/field/type or assemblies containing types referenced…


Where to Find Technical Support

Microsoft’s official support website is It has all kinds of resources like product FAQs, downloads, searchable KB articles, newsgroup pointers, and ways to reach people to help with your individual needs or feedback. Unfortunately, I can’t give attention to individual customer issues. That’s because I work in product design and development, not customer support….


Determining the Referencing Assembly

Say you’re debugging your application and you see that version 1.0 of an assembly is being loaded when you thought it should be version 2.0. Where is the reference to 1.0 coming from? The easiest way to find out is to look at the Fusion log for this bind. If the version 1.0 assembly was…



If a type can’t be loaded for some reason during a call to Module.GetTypes(), ReflectionTypeLoadException will be thrown. Assembly.GetTypes() also throws this because it calls Module.GetTypes(). The Message for this exception is “One or more exceptions have been thrown while loading the types” or “Unable to load one or more of the types in the…


Debugging Assembly Loading Failures

So…you’re seeing a FileNotFoundException, FileLoadException, BadImageFormatException or you suspect an assembly loading failure? Try the steps below to start your debugging process. First, get the Message property from the exception. If the exception’s InnerException property is set, get the Message property from that. If the message is generic, also get the hresult by calling System.Runtime.InteropServices.Marshal.GetHRForException(),…