views:

98

answers:

4

I have a library which contains unloadable type (whenever I try to access them I get a TypeLoadException). Therefore, I can't use the System.Reflection namespace to inspect those types. Is there some other way to reflect on those types. Of course, I don't expect to be able to use any methods, I just want to see basic info such as method names and perhaps the argument types.

Edit: I know and accept that the type is unloadable, it is because it defines its own System.Object and it does not have a reference to mscorlib. Reflector and ildasm work, but I want to do the reflection on the fly.

A: 

Check out this blog post: Debugging a MissingMethodException, MissingFieldException, TypeLoadException.

Mladen Mihajlovic
I know why the type can't be loaded and I accept it.
erikkallen
A: 

Try using Reflector - it should be able to show you some of the metadata about those types. If that doesn't work, try using ILDASM to disassemble the assembly to see the type's metadata.

Andrew Hare
Yes, both of those tools can do the inspection for me, but I want to do it in code.
erikkallen
A: 

Use Assembly.ReflectionOnlyLoad to load the assembly.

see msdn

Stefan Steinegger
He's getting a TypeLoadException when he does it.
Mladen Mihajlovic
Unfortunately, it doesn't make a difference.
erikkallen
+3  A: 

You could use Mono.Cecil to reflect the assembly. Unfortunately you'd have to change your reflection code as the interfaces are not compatible.

__grover