Search code examples
c#maf

MAF. Call from add-in side


I'm developing an application that provides plugins. I'm using Managed Add-In Framework for my aim. Is there a way to call host's method from add-in?


Solution

  • Yes, you define an interface in the contract (and in both views) and then you create a concrete implementation of that interface on the host adapter side and pass that into a method on the addin.

    One simple example would be having a logger interface (ILogger) and implementing a logger in the host view. Then you could create a AddInInitialize method in your contract that takes an ILogger. It can then call methods on that ILogger and it will go across the MAF boundry (cross process or not depending on your setup) to make the appropriate calls.