Updating Existing AddIn

Sep 19, 2008 at 9:24 PM

We are looking to build a generic task-processing engine for an application. (For example, our app needs to purge old files from archive directories, import new files if they are present, check

states at certain times and send notifications, etc.) We came across System.AddIn and have successfully created it. We can add and remove AddIns just fine. The problem we are having is how best to

update an existing AddIn.

In our design, it is expected that there will be one AddIn for a given "task". We may need to either fix a bug in that task, or update its functionality so that it performs it in a different way. We

need the identification of the AddIn itself (which we use for logging and communication purposes) to stay the same. So, even if we update it, we want the name of the AddIn token to stay the same.

We have tried to do this, but have not had success. We have been able to unload all AddIns, rebuilt the AddInStore, and even recreate the AddIns folder on the file system, all while the host is

running. We have also updated the Version on the AddIn attribute and updated the assemblies version info. However, when it reloads the AddIn, the code being executed is always the previous version.

It will not execute the new code until we restart the host process.

So, our goal is to not have to restart the host process. We want to be able to identify a given AddIn by name, and update it. I have now tried hosting the AddIns in an AddInProcess, however now I am

unable to rebuild the pipeline, and am getting exceptions.

Any advice would be greatly appreciated.


Sep 19, 2008 at 11:18 PM
Hi wl,

As long as you activate in either a separate AppDomain or a separate process, you should be able to unload and re-load newer versions of an add-in. Have you made sure you replaced the addin assembly in the <pipeline store>\AddIns\<add-in name> folder?

Changing the activation method (in-process vs. out of process) should not affect rebuilding the pipeline store. What exceptions are you getting?

Sep 19, 2008 at 11:33 PM
Thanks for the response. I gave up trying to update them in the AddInProcess. I am now doing the following:

1) I recompile the AddIn, giving it a new Version number in the AddIn attribute.
2) I create another directory in the AddIns directory for the new AddIn. (i.e. I may have TaskA. directory, and TaskA. directory)
3) I modified the code that loads the AddIn to look for the AddIn with the highest version number. (So in the above scenario I would only load the

The AddIns load just fine when the host process starts. However, if I attempt to reload a new AddIn, after having done the steps above, I see that it indeed will pull in the latest AddInToken, but when I now make a call against that AddIn, I now get a "The target application domain has been unloaded." exception. (System.AppDomainUnloadedException)

So, to show what the code is doing:

When host process launches:
  • AddInStore.Rebuild
  • For each token: token.Activate<OurTaskLibraryType>(AddInSecurityLevel.FullTrust)

When we (try) to do a refresh of the AddIns, we:

  • For each AddIn: AddInController.GetAddInController(addIn); controller.Shutdown();
  • AddInStore.Rebuild
  • For each token: token.Activate<OurTaskLibraryType>(AddInSecurityLevel.FullTrust)

When I debug the above, I can see that everything succeeds. But when I call a method on the AddIn after doing a refresh, I now get the AppDomain error.


Sep 22, 2008 at 5:09 PM
Nevermind! I just discovered that I inadvertently had an object reference that was stale. The AddIns were being successfully refreshed, but I was overlooking updating another variable used in task execution. Thanks again for your help!