By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,567 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,567 IT Pros & Developers. It's quick & easy.

application cannot read the app.config file

P: n/a
application cannot read the app.config file

i have a config file for the executable

i try to read it but it throws an exception

when building the setup for the project vs2005 do not add the
app.config automatically

public Form1()
{
InitializeComponent();

try
{
System.Configuration.AppSettingsReader
configurationAppSettings = new
System.Configuration.AppSettingsReader();

username =
configurationAppSettings.GetValue("username",
typeof(string)).ToString();
domain = configurationAppSettings.GetValue("domain",
typeof(string)).ToString();
senha = configurationAppSettings.GetValue("senha",
typeof(string)).ToString();
Comum.Utils.Impersonate.login(username, domain,
senha);
}
catch (Exception e) { MessageBox.Show(e.Message); }
}
Jul 15 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jul 15, 3:50 am, pedro <pe...@code4cerveja.comwrote:
application cannot read the app.config file

i have a config file for the executable

i try to read it but it throws an exception
What is the exception? Is you config file named exename.exe.config
as it should be? Any additional information would be helpful.

Chris
Jul 15 '08 #2

P: n/a
I must agree with Mr. Dunaway. We need more info to help.

What line is causing the Exception?

What does the Exception Message say?

What information is contained in your app.config file?

"Pedro for President"

"pedro" wrote:
application cannot read the app.config file

i have a config file for the executable

i try to read it but it throws an exception

when building the setup for the project vs2005 do not add the
app.config automatically

public Form1()
{
InitializeComponent();

try
{
System.Configuration.AppSettingsReader
configurationAppSettings = new
System.Configuration.AppSettingsReader();

username =
configurationAppSettings.GetValue("username",
typeof(string)).ToString();
domain = configurationAppSettings.GetValue("domain",
typeof(string)).ToString();
senha = configurationAppSettings.GetValue("senha",
typeof(string)).ToString();
Comum.Utils.Impersonate.login(username, domain,
senha);
}
catch (Exception e) { MessageBox.Show(e.Message); }
}
Jul 15 '08 #3

P: n/a
On Jul 15, 4:50*am, pedro <pe...@code4cerveja.comwrote:
application cannot read the app.config file

i have a config file for the executable

i try to read it but it throws an exception

when building the setup for the project vs2005 do not add the
app.config automatically
If you added the app.config by using the menu option it will be marked
as content.
If you ceated the file manually you need to set it to "Content"a dn
also "Copy always"

Also in the setup make sure that you select the "project output" as
the source of the setup.
Jul 15 '08 #4

P: n/a
On Jul 15, 1:50*pm, pedro <pe...@code4cerveja.comwrote:
application cannot read the app.config file

i have a config file for the executable

i try to read it but it throws an exception

when building the setup for the project vs2005 do not add the
app.config automatically

* * * * public Form1()
* * * * {
* * * * * * InitializeComponent();

* * * * * * try
* * * * * * {
* * * * * * * * System.Configuration.AppSettingsReader
configurationAppSettings = new
System.Configuration.AppSettingsReader();

* * * * * * * * username =
configurationAppSettings.GetValue("username",
typeof(string)).ToString();
* * * * * * * * domain = configurationAppSettings.GetValue("domain",
typeof(string)).ToString();
* * * * * * * * senha = configurationAppSettings.GetValue("senha",
typeof(string)).ToString();
* * * * * * * * Comum.Utils.Impersonate.login(username, domain,
senha);
* * * * * * }
* * * * * * catch (Exception e) { MessageBox.Show(e.Message);}
* * * * }

What does the exception.Message say?

-Cnu
Jul 16 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.