0

How to intercept methods calls during runtime, For example, I have a DLL of my application that contains some methods that I would like to bypass or intercept to add some logs.

Can I use some techniques of AOP like Dynamic Proxy / Methods Interception and how should this interact with my DLL?

My goal is to avoid, finding some methods, modifying them by adding some logs, or just bypassing them and recompiling the DLL again.

Mselmi Ali
  • 1,139
  • 2
  • 18
  • 28
  • Yes, you can use AOP via libraries such as Fody so long as _you_ are the one compiling those DLLs. If you truly want to use an existing DLL that you don't touch, you'll be out of luck. – Kirk Woll Jun 02 '22 at 14:11
  • When you say dll you mean an assembly? Not just any dll? – Ralf Jun 02 '22 at 14:16
  • Yes, an assembly. – Mselmi Ali Jun 02 '22 at 14:22
  • 1
    Then you might need to create some facade classes you have control over and instead of using the classes directly from that assembly use the facade classes that call the actual classes from that assembly and do what ever you need in the facades. – Ralf Jun 02 '22 at 14:32
  • 1
    It's hard to give a specific answer to such a broad and non-specific question. Read the documentation: https://github.com/castleproject/Core/blob/master/docs/dynamicproxy.md and re-work the question into something a bit more specific. – Krzysztof Kozmic Jun 20 '22 at 06:04

0 Answers0