I need some help with dynamic assembly loading.

I need to load a single assembly and its dependent assemblies (and theirs
too if required).  I already have a method that will get the assembly and
dependent assemblies.

I have this  section of code (this is test only):

    foreach (var item in allAssemblies) {
        var assm = item.GetAssembly();
    }

    foreach (var item in allAssemblies) {
        try {
            System.Reflection.Assembly ab = item.GetAssembly();
            Type[] types = item.GetAssembly().GetTypes();
        } catch (System.Reflection.ReflectionTypeLoadException ex) {

        }
    }

The GetAssembly() method above essentially does this:

return System.Reflection.Assembly.Load(data, null,
this.GetType().Assembly.Evidence);

The first assembly I come to is the primary assembly.  It has the type I
want to use.  The subsequent assemblies are the assemblies upon which the
primary assembly depends.
However, even though I've loaded all the assemblies, I get the
ReflectionTypeLoadException when I try to query the Types in the primary
assembly by using the GetTypes() method.

Any suggestions on how I can accomplish this?

Thanks,
Mike

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to