
下面是一些说明我的问题的示例代码.假设用户从不退出此应用程序,而是创建许多ICalculator实例.这些addIn进程如何处理掉?
static voID Main(string[] args) { string addInRoot = GetExecutingDirectory(); // Update the cache files of the pipeline segments and add-ins string[] warnings = AddInStore.Update(addInRoot); // search for add-ins of type ICalculator Collection<AddInToken> tokens = AddInStore.FindAddIns(typeof(ICalculatorHost),addInRoot); string line = Console.Readline(); while (true) { AddInToken calcToken = ChooseCalculator(tokens); AddInProcess addInProcess = new AddInProcess(); ICalculatorHost calc = calcToken.Activate<ICalculatorHost>(addInProcess,AddInSecurityLevel.Internet); // run the add-in Runcalculator(calc); } }解决方法@H_404_8@ 我设法找到了上述问题的解决方案,它正在使用AddInController类和它的shutdown方法.现在看看我是否可以在我的应用程序中使用它,而不仅仅是这个例子: static voID Main(string[] args) { string addInRoot = GetExecutingDirectory(); string[] warnings = AddInStore.Update(addInRoot); Collection<AddInToken> tokens = AddInStore.FindAddIns(typeof(ICalculatorHost),addInRoot); while (true) { AddInToken calcToken = ChooseCalculator(tokens); AddInProcess addInProcess = new AddInProcess(); ICalculatorHost calc = calcToken.Activate<ICalculatorHost>(addInProcess,AddInSecurityLevel.Internet); // run the add-in Runcalculator(calc); // shutdown the add-in when the Runcalculator method finishes executing AddInController controller = AddInController.GetAddInController(calc); controller.Shutdown(); } } 总结 以上是内存溢出为你收集整理的c# – 处理使用MAF创建的AddIns(System.AddIn)全部内容,希望文章能够帮你解决c# – 处理使用MAF创建的AddIns(System.AddIn)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)