[RESOLVED] App.exe.config file help needed
Hi again,
Ok, I'm trying to get my app.exe.config file working. So far there is just one piece of data that I want to store there, however this will build up as I get farther along in my project.
I've been following the post, http://www.vbforums.com/showthread.php?t=376190&, and when I copy and paste that code it works great (I've changed it just a tad bit but it works fine with my changes).
The problem is my project had an existing app.config file that I'm pretty sure I did not add myself, and I'm not sure how to meld the code of the two together, or if I even need the one that was already there. Here is what the existing code looks like:
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="frmDET.IsMdiContainer" value="False" />
</appSettings>
</configuration>
I've tried a couple different ways of adding them together (here is one example):
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<section name="start" type="System.Configuration.SingleTagSectionHandler" />
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="frmDET.IsMdiContainer" value="False" />
</appSettings>
<start dataconnstring="asdf" />
</configuration>
but each time I do I get an error: Unrecognized configuration section start (filepath line 9)
The weird thing is my frmDET has the IsMdiContainer=True set in design time, so I'm not sure how or what that app.config is doing. I guess vb must have added that for me for some reason.
Any help you can offer to get this going or on what that first config file may be would be really appreciated.
Thanks!
Essential
Re: App.exe.config file help needed
Try pulling your start section out of the appSettings tag. Also, I don't think SingleTagSectionHandler is supposed to be used for key/value pairs. Here's a small example of one of my configs:
HTML Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="DBlist" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<appSettings>
<add key="what" value="huh"/>
</appSettings>
<DBlist>
<add key="Local" value="server=(local);database=BillTest;Integrated Security=SSPI"/>
<add key="1Dev" value="server=SQL;database=H1;Integrated Security=SSPI"/>
<add key="Dev" value="server=SQL;database=H;Integrated Security=SSPI"/>
<add key="Test" value="server=SQLt;database=H;Integrated Security=SSPI"/>
</DBlist>
</configuration>
Re: App.exe.config file help needed
Thanks for the example W_B.
This is what I have now and it's working:
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="start" type="System.Configuration.SingleTagSectionHandler" />
</configSections>
<start dataconnstring="asdf" />
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="frmDET.IsMdiContainer" value="False" />
</appSettings>
</configuration>