none
When using Windows installer, the connectionstrings in app.config aren't picked up. RRS feed

  • Question

  • I have a VSTO Excel 2007 add-in that should read connectionstrings from the app.config file, and then let the user decide which database to connect to. This works fine when I debug it, but when I run the deployed version (done with Windows Installer) the connectionstrings aren't read at all. I have added the primary outputs from all the projects to the setup project. The app.config file is in the ExcelAddIn project, but not under the Excel heading. The class that manages the connectionstrings is in another project.

    Here is my app.config file:

    <?xml version="1.0"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
      </configSections>
      <connectionStrings>
        <clear/>
        <add name="MyEntities" connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/SymModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=myServer;initial catalog=myDB;persist security info=True;user id=myUser;password=myPassword;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
      </connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0"/>
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

    I use the following to get to the connectionstrings:

    System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConnectionStringsSection csSection = config.ConnectionStrings;

    I have tried to add the ExcelAddin.dll.config file to the setup project's folder in which the Release folder and .proj file are. I have set the app.config file's 'Copy to Output Directory' property to 'Copy always' and the Build Action property to 'Content'.

    Is there something worng with my app.config file, or why is it not picked up (the connectionstrings are not loaded into csSection) after I've run the installer?

    Thursday, September 19, 2013 12:24 PM