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.ContractControllerB ase' 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.