Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating <appname>.config file from an Custom Installer Class Action
    primarykey
    data
    text
    <p>I've tried updating my application's .config file during installer (<strong>via a .NET Installer Class Action</strong>). But, I can't seem to get ConfigurationManager to list any properties or be able to set anything.</p> <p>I learned of this approach from several stackoverflow posts that pointed me to this guide: <a href="http://raquila.com/software/configure-app-config-application-settings-during-msi-install/" rel="nofollow noreferrer">http://raquila.com/software/configure-app-config-application-settings-during-msi-install/</a></p> <p>I've investigated the differences between my project and his and noticed that my configuration files are formatted differently. I believe this has to do with the fact that i'm using "Settings" files. </p> <p>Config files formatted in the guide look like: </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;appSettings&gt; &lt;add key="Param1" value="" /&gt; &lt;add key="Param2" value="" /&gt; &lt;add key="Param3" value="" /&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>Where mine looks like:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" &gt; &lt;section name="MyAppName.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /&gt; &lt;section name="MyAppName.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /&gt; &lt;/sectionGroup&gt; &lt;sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" &gt; &lt;section name="MyAppName.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt; &lt;/sectionGroup&gt; &lt;/configSections&gt; &lt;userSettings&gt; &lt;MyAppName.Properties.Settings&gt; &lt;setting name="TESTSETTING" serializeAs="String"&gt; &lt;value&gt;asdfasdfasdf&lt;/value&gt; &lt;/setting&gt; &lt;/MyAppName.Properties.Settings&gt; &lt;MyAppName.Settings1&gt; &lt;setting name="VerboseErrorMode" serializeAs="String"&gt; &lt;value&gt;False&lt;/value&gt; &lt;/setting&gt; &lt;applicationSettings&gt; &lt;MyAppName.Settings1&gt; &lt;setting name="RunOnStartup" serializeAs="String"&gt; &lt;value&gt;True&lt;/value&gt; &lt;/setting&gt; &lt;/MyAppName.Settings1&gt; &lt;/applicationSettings&gt; &lt;/configuration&gt; </code></pre> <p>To shed some light on what was going on... I tried printing out the list of settings like so:</p> <pre><code> Configuration config = ConfigurationManager.OpenExeConfiguration(exePath); // Try getting the Settings1 Section AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("Settings1"); // Also tried myNamespace.Settings1 if (appSettings != null) { valList = "Settings1: "; foreach (string key in appSettings.Settings.AllKeys) { string value = appSettings.Settings[key].Value; valList += ("Key: '" + key + "' = '" + value + "'\n"); } } else { valList = "appSettings was null"; } MessageBox.Show(valList); MessageBox.Show(valList); </code></pre> <p>I have tried several permutations of this... and in all cases output is "appSettings was null".</p> <p>I also tried initializing the configuration manager in several different ways...</p> <pre><code> Configuration config = ConfigurationManager.OpenExeConfiguration(exePath); MessageBox.Show("Section Count: " + config.Sections.Count); MessageBox.Show("Has File: " + config.HasFile); MessageBox.Show("Namespace Declared: " + config.NamespaceDeclared); config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); MessageBox.Show("Section Count: " + config.Sections.Count); MessageBox.Show("Has File: " + config.HasFile); MessageBox.Show("Namespace Declared: " + config.NamespaceDeclared); </code></pre> <p>For each of them the section count returned was 20. (I have no idea where the 20 comes from... I would have expected it to be 3).<br> HasFile was true for the first case and false for the second. <BR> Namespace Declared was false in both cases. </p> <p>Thanks!</p> <p><strong>EDIT (6-18-09):</strong> Still looking into this question. Anyone else have any ideas? Thanks.</p> <p>Search Keywords: "Object Reference Not Set to not set to an instance" &lt;-- this occurs when trying to write to a property. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload