none
Has VS 2010 SP1 changed where the .config file is picked up from in VSTO add ins? RRS feed

  • Question

  • I have an Excel 2010 add-in that has various setting in the app.config file. This add-in is deployed using windows installer having the Visual Studio 2010 Tools for Office Runtime as a prerequisite which is automatically downloaded and installed from Microsoft's web site. (Through the link http://go.microsoft.com/fwlink/?LinkId=158917)
     
    This has been working fine until today, but now my add-in is not working anymore because it cannot find the settings in the .config file.
    What changed is that the VSTO version installed is now a different version than before. My add-in worked fine with VSTO v10.0.30319.308 but fails with the latest v10.0.31007. (Which comes with VS 2010 SP1 and the prerequisite link above.)
     
    Apparently there is a breaking change (or bug) in the new VSTO version which makes it not pick up the .config file of my add-in. I can get it to work by copying the add-ins .config file to the Microsoft Office folder and renaming it "Excel.exe.config", but this not a solution.
     
    Everything is working as expected in my development environment (with VS SP1), so how can I get it to work again when my add-in is deployed on a client computer?
     
     
    Thanks,
    Andrew

    Thursday, March 24, 2011 5:21 PM

Answers

  • I found a workaround.

    You can make sure your .config file is loaded by using this code:

    using System.Configuration;
    
    Uri codeBaseUri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
    string configFile = codeBaseUri.LocalPath + ".config";
    
    ExeConfigurationFileMap map = new ExeConfigurationFileMap
    {
       ExeConfigFilename = configFile
    };
    
    Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
    

    Andrew

    Friday, March 25, 2011 2:59 PM

All replies

  • I just answered this question on SO.  At least for a temporary fix.  So far I haven't seen anything from MS about this problem (I'm having the same problem with an Outlook Addin).  Your best bet is to uninstall VSTO v10.0.31007 and reinstall V10.0.30319.308 then rebuild your deploy package.  Any client machine with the newer version installed will be broken unless you uninstall the newer and reinstall the old.  Hopefully someone from the VSTO team acknowledges this bug soon.
    Thursday, March 24, 2011 7:00 PM
  • Hi Rob,

     

    Unfortunately uninstalling and re-installing the old version does not work. Once the v10.0.31007 has been installed it breaks it permanently.

    MS really has to address this soon!

     

    Andrew

    Thursday, March 24, 2011 8:16 PM
  • Strange thing is, I was able to uninstall the VSTO on one XP client machine and install the old VSTO setup and it did work.  I'm finding that isn't the case with Windows 7 client machines.  My dev machine is also hosed because the files in the Referenced Assemblies directory, which VS resolves to for dependencies, also still has the newer versions of the files.
    Thursday, March 24, 2011 9:21 PM
  • I found a workaround.

    You can make sure your .config file is loaded by using this code:

    using System.Configuration;
    
    Uri codeBaseUri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
    string configFile = codeBaseUri.LocalPath + ".config";
    
    ExeConfigurationFileMap map = new ExeConfigurationFileMap
    {
       ExeConfigFilename = configFile
    };
    
    Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
    

    Andrew

    Friday, March 25, 2011 2:59 PM
  • This is a great workaround, but it is still a problem for us because there are libraries we are referencing that we can't necessarily modify that are loading settings from the config file using ConfigurationManager.AppSettings["SomeValue"].

    So I think this really needs to be addressed ASAP... not to mention the fact that any customer who is deploying a currently released addin and installs the latest version of VSTO, won't be able to use that addin if the addin relies on values from the config file.

    Friday, April 1, 2011 4:14 PM