I am using an exe and a dll. dll actually connects to the database and
config file is in exe project. Same dll is used for another WebForms
interface and the appSettings section in Web.Config works well there. But
not in WinForms application.
I am using Beta2 of VS.
Can any one suggest a solution?
Rregards
Hemant
Steps:
1) Create an object representing all the config info you need (i usually use
properties for whatever values i need). You'll need to specify some
attributes on the properties or whatnot so take a look at the docs under
system.xml.serialization
2) Use System.Xml.Serialization.XmlSerializer to serialize it to a file
(something.config)
3) Edit that config file to your hearts content.
4) Deserialize just like you serialized.
This is basically what the Asp.Net runtime is doing when it loads an app but
it does it under the covers. There is no built in match for winforms AFAIK.
hth, Ryan
"Hemant Sathe" <hks...@hotmail.com> wrote
Make sure the following things
1) the config file must reside in the same directory as that of the EXE
2) the name of the config file must be myapp.exe.config - it is the same
name as that your app.exe with ".config" suffixed
3) the config file will look like
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="myconnect" value="provider=blah...blah" />
</appSettings>
</configuration>
4) In your app, use the following to get the values
System.Collections.Specialized.NameValueCollection configurationAppSettings
= System.Configuration.ConfigurationSettings.AppSettings;
MessageBox.Show(configurationAppSettings.GetValues("myconnect")[0]);
HTH
Regards
Kalpesh
"Hemant Sathe" <hks...@hotmail.com> wrote in message
news:eFKkINt2BHA.2760@tkmsftngp04...
Thanx again
Regards
Hemant
"Kalpesh Shah" <shahk...@hotmail.com> wrote in message
news:O#Joqst2BHA.2856@tkmsftngp05...