I am after ideas on how to call back to a main exe from a dynamically loaded dll ? (NB: this dll will be unloaded at some point after the callback)
Context C#
I am prototyping a service which during development then later on, can update its core. I have a stub main which will do the service calls into the “main dll”. I want to be able to call back into the main exe to tell it to reload the core dll after a fresh copy of the latest dll is done. I have the load – unload working. However I can’t get a callback or update of a passed IntPtr to work and other similar ideas to work. E.g.
loader.ExecuteStaticMethod(cMain_DLL, "Class1", "My_CallBack", new object[] {out _Count });
wont compile
I have used a slightly modified http://www.c-sharpcorner.com/uploadfile/girish.nehte/how-to-unload-an-assembly-loaded-dynamically-using-reflection/ to load and unload the dll, as well as call functions in the dll.
Type[] types = parameters.Select(o=>o.GetType()).ToArray();
MethodInfo MyMethod = MyType.GetMethod(methodName, types); <= can retun null for some objects
MyMethod.Invoke(inst, BindingFlags.InvokeMethod, null, parameters, null);