Search code examples
c#.netvisual-studio-2010.net-3.5console-application

How do I compile my App.config into my exe in a VS2010 C# console app?


I'm creating a console app in Visual Studio 2010 with c#. I want this app to be stand alone, in that all you need is the exe, and you can run it from anywhere. I also want to use app.config to store connection strings and so on.

My problem is that I can't seem to figure out how to include that app.config data into the compiled exe. I do see it creates appname.exe.config, but I don't want people to have to worry about grabbing two separate files when they get the app.

None of the googling I've done has come up with anything. Is this even possible?


Solution

  • You can't. Half the point of such config files is to allow changes to the configuration of the app outside of the app itself.

    You would simply have to modify your program so that it didn't have a dependency on the app config file -- easiest way to do that would be to just stick the values inside your config into read only global variables.