read app.config in addin

Feb 5, 2008 at 5:44 AM
My addins are running nicely. I am loading the addins within the current application domain , to make the load time faster. Loading is as follows:

addInToken.Activate<myAddIn>(AppDomain.CurrentDomain);

My addins sit in a different project to the shell. The shell is the host and it has its own App.Config. Each other project may have an app.config associated with it in order to be able to configure and read some settings for the addins. Now, because of all of them are running under the same App domain (to make addin load time faster), the app.config at the project level is not being read. I cannot place everything in one App.config.

Is there any way for the project containing the Addins to reference its own app.config and not refer only to the main app.config?

Thanks
Feb 5, 2008 at 5:44 PM
The app.config issue is one of the reasons we strongly recommend using AppDomain isolation for your add-ins. The CLR only allows one app.config per domain and it can not be changed/modified once the domain has started up and so only if you give each add-in its own domain can you give then their own app.config files.

If you do choose to use AppDomain isolation for the add-ins we will look for a config file next to the add-in, just as we do for exe's, in the format of filename.dll.config.

Additionally, if you wish to pull a config file from a different location than the one next to the add-in you can create a new AppDomain for us and set the config file to be whichever one you wish. We generally recommend against doing this though because you lose some other benifits (for example, System.AddIn will never unload an add-in that you create, but if detect that an AppDomain we created no longer has any add-ins running in it we'll automatically unload it for you) but it is certainly an option if you have specific needs.

--Jesse