Can AddIns in MAF (System.AddIn) have constructor parameters?

575 Views Asked by At

I need to pass configuration settings to an AddIn created using the Managed AddIn Framework (MAF, aka System.AddIn). Can a put a settings parameter in the AddIn's constructor?

Another option would be to create an Initialize() method, but then I have to remember to call it before doing any work with the AddIn.

2

There are 2 best solutions below

0
On BEST ANSWER

Best way is to use Initalize() method, because the pipelines use the constructor parameters for passing contracts.

1
On

I too use an Initialize() method in my add-ins. Indeed System.AddIn invokes the parameterless constructor of the add-in class.

Here is an explanation of what goes on during the activation of an add-in. It is an old post but the activation process is still the same. You can also check the source code of the System.AddIn assembly from Microsoft's Shared Source Initiative. You can download the one with Product Name = .Net and Version = 4 for Framework 4, install it and then look for AddInToken.cs (it will lead you to AddInActivator.cs).