manually loaded assembly fails to find its referenced assemblies

B

Bob

For an assembly I manually load from a file, this code snippet:

For Each t As Type In asm.GetTypes
'do something
Next

generates this error message:

System.Reflection.ReflectionTypeLoadException: One or more of the types in the
assembly unable to load.
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at ....

So I thought, fine, before calling GetTypes I can manually load the referenced
assemblies because I already know where they are.

For Each refasmname As AssemblyName In asm.GetReferencedAssemblies
Try
Dim asmtoload As String = DirectoryLocation & refasmname.Name & ".dll"
asm.LoadFrom(asmtoload)
Catch
End Try
Next

Even if all referenced assemblies are found and loaded, though, this technique
doesn't work all the time and I'm not quite sure why. Is there some way I can
say, "hey, you, assembly! - go look *here* to resolve references you can't
find"?

thanks in advance for any help,

Bob

P.S. Using the GAC is not an option.
 
B

Bob

This works when all the refereced assemblies that are not in the GAC are copied
locally in the project. I still can't figure out how to pass mutiple reference
paths to the AppDomain....

Dim domaininfo As New AppDomainSetup
domaininfo.ApplicationBase = "file:///" & FilePath
secDom = AppDomain.CreateDomain("SecondaryDomain", Nothing, domaininfo)

Please clue me in. I'm wasting a lot of time on this... :(

Bob
 

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