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

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?

我需要將配置設置傳遞給使用Managed AddIn Framework(MAF,又名System.AddIn)創建的AddIn。可以在AddIn的構造函數中放置一個設置參數嗎?

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 个解决方案


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



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).

以下是對加載項激活期間發生的事情的解釋。這是一個老帖子,但激活過程仍然是相同的。您還可以從Microsoft的Shared Source Initiative檢查System.AddIn程序集的源代碼。您可以為Framework 4下載Product Name = .Net和Version = 4的那個,安裝它然后查找AddInToken.cs(它將引導您進入AddInActivator.cs)。



粤ICP备14056181号  © 2014-2021