I'm sure there's a way, but off the top of my head, you can put a meaningless appSettings entry in the App.config, and check for the value of that at the beginning of Main (or if you have a real one already, just check for that one) - if it's not there, just throw out an error message to the UI and exit the application.
On Jun 7, 5:49 pm, Benj Nunez <[email protected]> wrote: > Hello experts, > > I would like to know if there is a way to programmatically determine > if the app.config > is present before the application can be run? You see, I've been beta- > testing my own > application. Intentionally I renamed my "app.config" to > "app.config.orig" (or something else > if you may). The program or at least, the CLR should be able to warn > me about a missing dependency file. > > After renaming the app.config, the program still runs. But naturally, > as you begin > accessing its visual controls to perform a database action which > involves instantiating > objects and such, I would get an error like: "Object reference not set > to an instance of an object." > > So, before it gets to that, I want to be able to detect the presence/ > absence of > the app.config at run-time. How do I do this? A simple File.Exists() > call won't do much. > > Benj
