C# – How does reflector show types when Assembly.GetTypes() fails due to a missing referenced assembly

creflection

I have a broken Assembly that I want to reflect over, its not broken badly, it just cannot find a referenced assembly, so it does fail a PEVerify. But….Assembly.LoadFrom() will still load it and GetTypes() will throw a ReflectionTypeLoadException, the .LoaderExceptions array shows me what referenced assembly cannot be found. At this point I am roadblocked.

However, the great little tool Reflector is able to go further and actually display the contained types, and handles gracefully the missing reference issue by giving me a pop-up dialog to browse for it. My question is, How after the GetTypes() fails does reflector manage to get the types anyway?

Best Answer

Reflector doesn't use System.Reflection to analyse an assembly.

I don't know which library Reflector uses, but you might want to have a look at Cecil.