Hey all,
I'm having some issues retrieving the Type information of a .dll, using Reflection. To give some background, I need to dynamically call particular functions within a .dll from a seperate class. This is a code snippet that I'm using right now:
Type[] types = assembly.GetTypes(); string ClassName = types[0].FullName;Instance = assembly.CreateInstance(types[0].FullName);
This worked just fine, but then I changed the .dll class from this:
class
Test {to
class
Test : BasicEngineWrapper.EngineUtilities, BasicEngineWrapper.IEngineWrapperBasicEngineWrapper.Engine.Utilities is an Abstract Class and BasicEngineWrapper.IEngineWrapper is an interface.
I get an error at: "Type[] types = assembly.GetTypes()", it reads "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information".
I've been trying to fix this for quite a while, although I'm not to familiar using Reflection. Mabye I'm not using these methods correctly, any help would be much appreciated.
Tony
Tony CastroPosted Jul 30, 2008, 8:44 PM
AlanPosted Jul 30, 2008, 7:17 PM
Bechir's point is that the Assembly.GetTypes() method won't be able to load a type which depends on other types contained in another assembly unless that assembly is loaded as well.
So, you'll need to load the assembly containing the types BasicEngineWrapper.EngineUtilities and BasicEngineWrapper.IEngineWrapper first.
A read through the documentation for the GetTypes() method may make the point a bit clearer:
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettypes.aspx
Tony CastroPosted Jul 30, 2008, 6:29 PM
Bechir BejaouiPosted Jul 30, 2008, 5:30 PM
Bechir BejaouiPosted Jul 30, 2008, 5:30 PM