Re: app.config
- From: "John Vottero" <John@xxxxxxxxx>
- Date: Wed, 22 Jun 2005 16:31:16 -0400
"Paul Daly (MCP)" <PaulDalyMCP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A374F7D5-361F-487F-AF29-BC344D18512E@xxxxxxxxxxxxxxxx
> OK... this is weird.
> I noticed that the app.config file wasn't being copied into the Debug
> directory after i compiled the application, so I did it manually. It
> didn't
> work... so I changed the name to App.exe.config and it worked perfectly.
>
> Now I need to find out how to tell Visual Studio to include this file in
> teh
> Debug directory when compiling... I'll post once I find out incase others
> run
> into this issue.
Some of what you're saying doesn't make sense. I don't think that
App.exe.config will work unless your executable is App.exe.
You're supposed to create a file named App.config in your Visual Studio
project and when you build, Visual Studio will copy App.config to
Programname.exe.config in the output directory. You said that you tried
Programname.exe.config but, was that the name in the output directory or in
Visual Studio? Visual Studio won't copy that to the output directory, it's
only looking for App.config.
>
> -Thanks,
>
> Paul
>
> "Paul Daly (MCP)" wrote:
>
>> I've created a windows forms appliation that gets its data from a sql
>> database.
>>
>> I want to create an app.config file for this application so that in the
>> event that the server name changes, they won't have to recompile to
>> connect,
>> but rather change the setting in the app.config file.
>>
>> I've seen many examples of this online and have done this a number of
>> times
>> myself in ASP.net with the web.config file, however, I am having issues
>> getting it to work this time.
>>
>> Here is the App.config file
>>
>> <?xml version="1.0" encoding="utf-8" ?>
>> <configuration>
>> <appSettings>
>> <add key="ConnectionString" value="Password=Password;Persist Security
>> Info=True;User ID=User;Initial Catalog=Database;Data
>> Source=DatabaseServer;"
>> />
>> </appSettings>
>> </configuration>
>>
>> And in my DAL i access this key the following way...
>>
>> private static string sqlConn =
>> ConfigurationSettings.AppSettings["ConnectionString"];
>>
>> I have included the reference to System.Configuration in the DAL.
>>
>> This code compiles, but gives me a runtime error that states "the
>> connection
>> string property has not been initialized".
>>
>> When I MessageBox.Show(sqlConn)... I see nothing.
>>
>> When I statically define sqlConn, everything works fine.
>>
>> Do I need to somehow explicitly tell the windows forms project to look at
>> the App.config file?
>>
>> Also, I have renamed the app.config file to ProgramName.Config. Does
>> this
>> have any ramifications? (It doesn't work when I change it back to
>> App.config).
>>
>> Thanks in advance for your help!
>>
>> -Paul
.
- References:
- app.config
- From: Paul Daly (MCP)
- RE: app.config
- From: Paul Daly (MCP)
- app.config
- Prev by Date: Write data to Excel file
- Next by Date: Highlighting tabs in a TabControl
- Previous by thread: RE: app.config
- Next by thread: Re: app.config
- Index(es):
Relevant Pages
|