Say I have a private, “instance”, non-static bool method in a third-party dll. This whole method returns a value. Nothing more. How can I intercept calls to this method, change its OpCodes IL / method body, or redirect it to an additional, overridden, or derived method.
I do not want to decompile a third-party dll, manually change the source and recompile it. I would also prefer not to save the assembly to disk, as this also involves using a “recompiled” assembly instead of the original.
Basically I want to be able to use the original dll - no replacements or file changes. I just want to do what I said above.
Is there any way to do this? If so, can you develop or publish links / tutorials, etc.
In addition, I know about virtual, overriding, and new modifiers, but I remember that I: do not have the source of the mentioned third-party DLL, cannot access the source, I do not want to decompile something like dotPeek and recompile.
Thanks!
Edit: I forgot to mention the rest of the infrastructure: MainProgram loads ThirdPartyDLL. MainProgram also downloads MyPluginDLL. I am trying to change a method in ThirdPartyDLL from MyPluginDLL, so that when MainProgram calls the specified method, it will call the changed method. I want to be able to do this WITHOUT saving the new assembly and restarting MainProgram with the new assembly. Essentially, I want to do this either at startup or at launch of MainProgram.