jeudi 26 septembre 2019

On loading an assembly/dll after a method is invoked via reflection, the method invocation throws "Object does not match target type" exception

I have a test tool developed using .net framework c#. I have a DLL which contains all the interfaces to and method that need to be invoked during runtime.

The application is started and this loads the assembly to memory using Assembly.Load(ReadAllBytes(path)) method and once the assembly is loaded, the types are fetched and required methods are invoked via reflection.

But after invoking a method if I load the assembly again and try invoking the same method, I get an exception from RunMethodInfo class CheckConsistency method.

"Object does not match target type"

Is it not possible to load the assembly after calls are made through reflection?

If I never run any method and load the assembly several times before, everything works fine. I am not understanding which object it is referring to ? Kindly help.





Aucun commentaire:

Enregistrer un commentaire