I need to load a DLL dynamically so I can compare two identical methods from different DLL version, without using Web-services.
I already did that on an other project, and it worked perfectly.
But the Dll I need to import is more complex now, it uses C++ dll reference etc.
Here is the part of code :
Type type1 = dll1.GetType("MyNamespace.MyClass");
var instance1 = Activator.CreateInstance(type1, "some string", "some string", "some string");
MethodInfo myMethod1 = type1.GetMethods().Where(X => X.Name == "myMethod").FirstOrDefault();
object retour1 = (object)myMethod1.Invoke(instance1, new object[] { fichier.FullName, dossier.FullName, null, false, null });
The last line of code return a "System.Reflection.TargetInvocationException" apperently in "mscorlib.dll"
Since I am quite new to reflection, I do not really know what is happening, is this because of c++ dll, or did i forget something? The same code works on simpler DLL.
Maybe there is a better way to do this task, but as I cannot do the following :
Using myLib
Using myLib
I am stuck, any help would be very appreciated =)
Aucun commentaire:
Enregistrer un commentaire