471,357 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

application cannot read the app.config file

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
4 3928
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
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
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
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.

Similar topics

2 posts views Thread by Wayne | last post: by
7 posts views Thread by Steven Cliff | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.