Re: app.config



"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


.



Relevant Pages

  • Re: Strong naming assembly in an vb aspx project
    ... The placement of key depends on what mode are you compiling your vb project ... the same as the output directory, which usually is \bin (relative to the ... If the solution configuration is in the default Debug mode, ... I get the error "Error creating assembly manifest: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Inherit a class which is in a separate file ?
    ... Thank you, but i am using notepad to program, not visual studio. ... want to debug and run the software prior to compiling. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: newbie question
    ... >> Now do I need Visual Studio .NET, ... > compiling without Visual Studio, ... > uses compiled DLLs with ASPX page templates. ... it passes it off the the HttpHandler for that type ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Problem with Registering filter on windows mobile
    ... The fix is to modify C/C++ preprocessor definitions in the ... unresolved external because it's only defined in debug builds, ... the project using the visual studio wizard it worked, ... Windows CE Multimedia and Graphics ...
    (microsoft.public.windowsce.app.development)
  • RE: debugger doesnt stop at breakpoint while debugging SQLCLR functio
    ... It seems remote debugging component was not installed during Visual Studio ... I click Step into Function and I am able to debug the function step by step. ... Stored Procedure is in separate assembly which is created in SQL Server ...
    (microsoft.public.vsnet.debugging)