application cannot read the app.config file

P

pedro

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); }
}
 
C

Chris Dunaway

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
 
J

jp2msft

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"
 
I

Ignacio Machin ( .NET/ C# MVP )

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.
 
D

Duggi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top