Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I came across the same problem, after deep investigation, I found out the easiest way to update any part of config files (e.g. app.config), that's by using XPath. We have an application which connects to web service, during the installation, the user enters the URL of the web service and this should be saved in the following app.config file:</p> <pre><code> &lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt; &lt;section name="ApplicationServer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt; &lt;/sectionGroup&gt; &lt;/configSections&gt; &lt;applicationSettings&gt; &lt;ApplicationServer.Properties.Settings&gt; &lt;setting name="ApplicationServer_ApplicationServerUrl" serializeAs="String"&gt; &lt;value&gt;whatever comes from setup should go here&lt;/value&gt; &lt;/setting&gt; &lt;/ApplicationServer.Properties.Settings&gt; &lt;/applicationSettings&gt; &lt;/configuration&gt; </code></pre> <p>Here is the code to do this in the installer class:</p> <pre><code>public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); string targetDirectory = Context.Parameters["targetdir"]; string param1 = Context.Parameters["param1"]; string path = System.IO.Path.Combine(targetDirectory, "app.config"); System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.Load(path); System.Xml.XmlNode node = xDoc.SelectSingleNode("/configuration/applicationSettings/Intellisense.ApplicationServer.Properties.Settings/setting[@name='ApplicationServer_ApplicationServerUrl']/value"); node.InnerText = (param1.EndsWith("/") ? param1 : param1 + "/"); xDoc.Save(path); // saves the web.config file } </code></pre> <p>Basically, since the config file is a XML based document, I am using XPath expression to locate specific node and change its value.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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