ShadowCopy for AddIns

Jul 25, 2008 at 11:06 PM

I'm trying to enable ShadowCopy for AddIns.
I was thinking of setting up my own AppDomain, but for that I need to supply a BaseDirectory which points to the Add-In assembly location.
That location is AFAIK unkown until the addin has been activated, and then it's too late to set ShadowCopy.
Any ideas how to enable ShadowCopy for an AppDomain created by the Activate method?

thanks
Rai
Jul 26, 2008 at 1:16 AM
Edited Jul 26, 2008 at 1:18 AM
Hi raidevnet,

You can use something like the following code to create app-domains with shadow copy enabled, and use those app-domains to activate add-ins. (Note that you don't need to supply a BaseDirectory explicitly; it uses the host's base directory. If you don't specify a value for ShadowCopyDirectories, it will cache everything under the base directory)

var appDomainSetup = new AppDomainSetup();  

appDomainSetup.ShadowCopyFiles =

"true";

 

 appDomainSetup.ApplicationName =

"myapp";

AppDomain domain = AppDomain.CreateDomain("MyAD", AppDomain.CurrentDomain.Evidence, appDomainSetup);

ShapeAppViews.
IShapeAddIn addIn = token.Activate<ShapeAppViews.IShapeAddIn>(domain);
This works if your addins live under the host app's folder. If they don't, you can set BaseDirectory to whatever path you passed into AddInStore.FindAddIns().

-Mueez
Jul 26, 2008 at 1:46 AM
Thanks for your reply Mueez.

I suspect that each of the Add-Ins' AppDomain.CurrentDomain.BaseDirectory will point to the host's BaseDirectory.
They will no longer be able to use the App.config that is each addin's individual folder.





Aug 14, 2008 at 4:35 AM
Yes, you are right. I can look into exposing the add-in's directory as a property of AddInToken.

But for now, unfortunately, there's no easy way to specify both the addin's config file and turn on ShadowCopy.

-Mueez