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

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.


I can see where you are going with this, but the answer might be a bit more complicated than you were looking for.

  1. Make app.config to be an embedded resource.
  2. Manually parse the app.config to get default app settings / connection strings / etc
  3. Still look for an app.config and override the defaults you read in earlier with the app.config values

This way you have some reasonable defaults that you don't have to maintain separate from you app.config as constants, you can run your app as just an exe, and you can still modify it at runtime by adding back in the app.config.

The one thing to remember, is that reading in the app.config from a resource won't give you the same behavior as the normal app.config. You are basically reading it in and using it by hand.


You mean you need to add it to the exe as a resource? Well, first of all you cannot, app.config is file based not resource based.

On the other hand, the only point of config file is that you can change it. Otherwise just hard-code or use constants.