Reflection GetType() problem.

L

Livingston George

Hi,

I am using Reflection to load an assembly dynamically and calls methods on
one of its objects.

myassembly = Assembly.LoadFile("C:\MyAssembly.dll")

Dim myType as Type = myassembly.GetType("MyAssemblyNamespace.MyObject")


The above code was working fine until today.

Now, GetType returns nothing always. I checked with MSDN and tried to use
GetTypes() method which will load all the available types of the assembly.
But it is throwing me an error saying.

"System.Reflection.ReflectionTypeLoadException - One or more of the types in
the assembly unable to Load".

I dont understand why this was working so far and suddenly stopped working.

I did not change any code in my application or this assembly file.

Some other groups have suggested that if any of the assemblies which our
Reflection assembly (MyAssembly.dll here) is refering is unavailable then we
could run into this problem. But does it mean that I put all the assemblies
"Myassembly.dll" is refering too? Even the System assemblies and
InteropAssemblies??


Please give me a clear solution as I could not get it anywhere else.

Thanks and Regards,
Livingston George.
 
G

Guest

You will need to have immediate dependancies available in the bin directory for those items not found in the GAC. All system stuff will be in the GAC and is not required to be placed into your bin dir. But if your MyAssembly depends on FooAssembly then FooAssembly must be available - Reflection walks the types in a resolution phase, which results in the error you are getting.
 

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