Machine config instead of app.config files for console apps
Is it possible to use connection strings 开发者_开发技巧in a Console app's app.config file in a single machine config file instead? So all console apps on the server can use the same file?
You could, but that would mean that any .NET application could gain access to your database.
I would advise against it, for several reaons:
- A possible security hole.
- Most developers would look for this information in
app.config
notmachine.config
. - You may end up sharing connection strings that only one or two applications need with all applications.
- You can't limit what applications will be able to use the connection strings.
- You will not be able to simply move the application to another machine, with the
app.config
file and have everything just work (you will also need to import the connection string information to the newmachine.config
).
You really should keep the configuration with the application that uses it.
精彩评论