Reflection Issue / Question

K

knightrider

I am trying to iterate through all of the assemblies in the share that
is our production source code repository and gather information about
the assemblies (number of classes and methods contained in each).

My problem is that many of the assemblies reference other assemblies
that causes the call to myAssembly.GetTypes() to fail with the
following error:
"Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information."
"Could not load type
'MyCompany.BizTalk.Contracting.ContractControllerBase' from assembly
'ContractControllers, Version=1.0.2657.26442, Culture=neutral,
PublicKeyToken=null'.
and
"Could not load file or assembly 'Microsoft.XLANGs.BaseTypes,
Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified."

For my purposes, I don't care about loading the assemblies that my
assembly depends on, I just want information about the "current"
assembly that I just loaded. I'm using Assembly.LoadFrom(fileName)
and have tried Assembly.ReflectionOnlyLoadFrom(fileName), but neither
works for me. (side note: why doesn't ReflectionOnlyLoadFrom work
since it's not supposed to load the dependent assemblies?)

I want to know how to interrogate and assembly without having to have
all the dependent paths resolved. I know "Lutz Roeder's .NET
Reflector" can do this without resolving or loading the dependent
assemblies.

Any advice would be greatly appreciated.
 
M

Mattias Sjögren

(side note: why doesn't ReflectionOnlyLoadFrom work
since it's not supposed to load the dependent assemblies?)

It doesn't automatically load them, but that doesn't mean the
dependencies are not needed. It just means it will have to manually
take care of loading them and handling the
AppDomain.ReflectionOnlyAssemblyResolve event.

I want to know how to interrogate and assembly without having to have
all the dependent paths resolved. I know "Lutz Roeder's .NET
Reflector" can do this without resolving or loading the dependent
assemblies.

Reflector doesn't use reflection AFAIK.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top