I have a very serious problem. A Customer has a SQL-Server. With Data. And the Application I made is only for Internal Usage. (Therefor there is no Webservice, etc. necessary) The Program works with a DataSet and its through an ConnectionString connected to the Database. The Connectionstring is stored in the App.Exe.Config which i didn't choose. It was made by the DataSet. The ConnectionString is at start empty. But the Data for the Connection is stored in an encrypted file. I am reading the Data and putting it into the connectionString.
The Code below works perfectly when I'm debugging.
BUT the Problem is now: I've created an Installer and now after the installation in the Program Files Folder it says it has no authorization to save the config. I mean I know what that means, and all. But is there a way that the application can save it? When i Opened it as an Administrator it saved the config. Set Full Access to "Everyone" didn't work.
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var connectionStringsSection =(ConnectionStringsSection)config.GetSection("connectionStrings"); connectionStringsSection.ConnectionStrings["ApplicationName.Properties.Settings.managementSQLConnectionString"].ConnectionString = String.Format(@"Data Source={0}\{1};Initial Catalog={2};User ID={3};Password={4};MultipleActiveResultSets=True", _DatabaseLocation, _DatabaseName, _Catalog, _Username, _Password);
try {
config.Save(ConfigurationSaveMode.Full);
}
catch (Exception err) {
NotificationController.Notify("Config-Error", err.Message,
System.Windows.Forms.ToolTipIcon.Warning);
}
ConfigurationManager.RefreshSection("connectionStrings");