public static T DefaultFactory<T>(AddInFacade addInFacade, AddInToken addInToken, Platform addInProcessPlatform) { var addInProcess = addInFacade.CreateAddInProcess(addInProcessPlatform); addInProcess.Start(); T instance; try { instance = addInToken.Activate<T>(addInProcess, AddInSecurityLevel.FullTrust); } catch (Exception e) { const string errorTemplate = "Unable to activate add-in named '{0}', version {2}, published by '{1}' out-of-process under platform {3}."; var errorMessage = String.Format(errorTemplate, addInToken.Name, addInToken.Publisher, addInToken.Version, addInProcessPlatform); throw new InvalidOperationException(errorMessage, e); } return instance; }
protected RestartableAddIn(AddInFacade addInFacade, AddInToken addInToken, Platform addInProcessPlatform) : base(() => AddInFacade.DefaultFactory <T>(addInFacade, addInToken, addInProcessPlatform)) { }