jeudi 22 octobre 2020

Missing references while calling another application method using reflection

I am trying to call a method in winForms application from a command line application using reflection : This method launches the application with loaded configuration.

Assembly exeApp = Assebmly.LoadFile(exeAppPath);
Type classType = exeApp.GetType(nameSpace);
object obj = classType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
MethodInfo exeMethod classType.GetMethod(MethodName);

exemethod.Invoke(obj, args);

Using this, I am able to call the method, but I get FileNotFound exceptions for all referenced assemblies in my target exe. If I add references to all those assemblies in my command line app, it works correctly.

The problem here is, the exe references keeps on changing/updating as per releases, and it makes difficult to update/release commandLine app everytime.

Is there any way I can make it work without adding the references in commandLine app ?

Many Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire