Skip to main content

Cloud

Config Files in Office Add-ins

I’m writing a Microsoft Office Add-in in .NET 2.0. The add in is a .DLL of course. As you probably know, DLLs do not read their own config files. Instead they get the config from the executables that started the DLLs. What this means is that if we want to load values from a config file in the DLL we have 3 choices (well maybe more but…)

1) We can modify the config file of the executable. For instance, we can modify (or create) the winword.exe.config file and put our values there. This is NOT a good idea of course.

2) We can create a shell that loads our DLL in a separate application domain and give that domain its own config file. This is a common practice, but I didn’t want to go that route and find out that the application domain has different security than Office and it will not load.

3) Read our own config file. This is the solution I chose to take. Attached you will find a helper class, I created for that purpose.

This helper class only exposes a few methods for example. Additional methods can be created if you need them.

I’m also attaching a sample config file. Notice that the name of the config file is the name of the DLL with a suffix of “.config”.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

PointBridge Blogs

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram