I’m dealing with a .NET windows form application written in C#, using entity framework for database connection. The connection string is written in app.config. The point is that I modify the application in order to switch between two different databases: a SQL server express 2008 and a SQL compact 4. In case the application cannot connect to SQL server, it modifies the app.config connection string section to resolve a name in order to connect with the local database (SQL compact 4). The problem is that in some computers is operation is firing an exception: access to the path denied, where the path is the one where the application is installed. How could I possibly overcome this problem?
I’m dealing with a .NET windows form application written in C#, using entity framework
Share
A user-mode application should not attempt to write to disk anywhere except in the user’s profile. That means that anything in
c:\Program Filesshould be off-limits to the program, unless it is an administrative program (and therefore would demand elevation in Win7/Vista).Windows XP systems with users running as admin probably work fine; But Vista/7 systems might experience exceptions, or even silently-failing edits. (due to being redirected to a user-specific copy of the app.config, instead of the real one).
You should instead store the various connection strings in the app.config, and provide a way for the user to select from them in your application. You can use user settings to save which string was used last.