Let's say I have a private, "instance," non-static, bool method in a third-party dll. All this method does is return a value. Nothing else. How would I go about intercepting calls to this method, changing it's IL OpCodes/method body, or redirecting it to an extra, overridden or derived method.
I do not want to decompile the third-party dll, manually change the source, and recompile it.
I also would rather not to save the assembly to disk as this would also involve using a "recompiled" assembly instead of the original.
I basically want to be able to use the original dll - no replacements or file changes. I just want to do what I mentioned above.
Is there any way to go about this? If so, can you elaborate or post references/tutorials/etc.
Also, I know of virtual, override, and new modifiers, but remember that I: do not have the source of said third-party dll, cannot get access to the source, do not want to decompile with something such as dotPeek and recompile.
Thanks!
Edit:
I forgot to mention the rest of the infrastructure:
MainProgram loads ThirdPartyDLL.
MainProgram also loads MyPluginDLL.
I'm trying to change a method in ThirdPartyDLL from MyPluginDLL so that when MainProgram calls said method, it will call the changed method. I want to be able to do this WITHOUT saving a new assembly and restarting the MainProgram with the new assembly. Essentially, I want to do this either at startup or when MainProgram is running.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…