App.Config files with VSTO 4.0 SP1

Using an app.config file is a great way to load settings for your add-in at runtime and the VSTO 4.0 runtime supports this, but what you might not know is that a small change in VSTO 4.0 SP1 might keep your app.config file from loading.

Here is a blog post from the Visual Studio Office Development Support team that describes the situation and a suggested fix…https://blogs.msdn.com/b/vsod/archive/2011/06/14/vsto-4-0-sp1-will-cause-a-vsto-addin-to-not-find-its-config-file.aspx

This post was helpful and resolved the issue so that my config file could be loaded when my add-in was running with Excel 2010 as the host application.  However this did not resolve the problem entirely because I setup my add-in to support both Excel 2010 and Excel 2007.  If Excel 2007 attempts to load my add-in with the Manifest setting set to file:///… the add-in actually gets set to Inactive and does not load in Excel.

A quick fix that supports both 2007 and 2010

All you need to do is use file:// ( notice only 2 / characters ) instead of file:/// and your config file will get loaded in both the 2007 host and the 2010 host.

Note: I have not tested this with all VSTO 4.0 host applications like Word, PowerPoint and Visio but I assume they would all have this issue as they all share the VSTO 4.0 runtime.