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…

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.

Comments (1)

  1. Anonymous says:

    This was a huge breakthrough for a similar problem I had with an Excel Document Level VSTO solution I developed. Certain machines appeared to ignore changes to the *.dll.config file while others worked fine. I believe I had the same issue described above however I'm working with a document level customization and not an application add-in.

    Changing the _AssemplyLocation under custom advanced properties of the workbook with the customization

    from: solutionName.vsto|8x4x73x8-d2xb-43×3-9x0x-e7x43fxf3xd3|vstolocal

    to: file://C:/Program Files (x86)/solutionInstallPath/solutionName.vsto|8x4x73x8-d2xb-43×3-9x0x-e7x43fxf3xd3|vstolocal

    sorted out these issues and settings in configuration file worked again.

    Figured I'd add a comment for anyone looking for similar problem. I spent many hours looking for a solution.