static Settings()
    {
      //load DB based settings...
      using (Proc ControlCentral_s = new Proc("ControlCentral_s")) _DBSettings = ControlCentral_s.ExecuteNameValueCollection();

      //load "app.config" file based settings...
      //it should be noted that *saving* *directly* to the app.config file is a well known no-no... from a security standpoing which isn't really elaborated on much that i can find
      //but that winds up meaning that the *Application* scoped settings accessible via {appname}.Properties.Settings.Default are code gen'd as read only properties.
      //there's lots of folks whining about wanting to *write* to these properties for various reasons out in the forums...
      //the main reason here is that we want the printer mappings to be settable by all users but at the application wide level not user based... 
      //i.e. we don't want every user to be required to select the same printers that everybody on this machine will be using
      //i feel like i basically get the security implications that the administrator/installer must open read/write ACL on the Program Files\{app} folder and app.config file
      //probalby because you can throw config info in those files which opens up even more access or something like that
      //anyway, i'm still going for it until i read more about it... found the following code here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/13428050-4fde-4c34-90f8-5255f4123a20/
      
      ConfigurationSectionGroup applicationSectionGroup = appConfig.GetSectionGroup("applicationSettings");
      applicationSettingsSection = applicationSectionGroup.Sections[ReflectionHelpers.CurrentAppName + ".Properties.Settings"] as ClientSettingsSection;
      applicationSettingsSection.SectionInformation.ForceSave = true; //crucial, otherwise just doesn't save, even though documentation indicates that it supposedly means save even if there aren't changes
      App = new SettingElementCollectionWrapper(applicationSettingsSection.Settings);

    }
Example #2
0
        static Settings()
        {
            //load DB based settings...
            using (Proc ControlCentral_s = new Proc("ControlCentral_s")) _DBSettings = ControlCentral_s.ExecuteNameValueCollection();

            //load "app.config" file based settings...
            //it should be noted that *saving* *directly* to the app.config file is a well known no-no... from a security standpoing which isn't really elaborated on much that i can find
            //but that winds up meaning that the *Application* scoped settings accessible via {appname}.Properties.Settings.Default are code gen'd as read only properties.
            //there's lots of folks whining about wanting to *write* to these properties for various reasons out in the forums...
            //the main reason here is that we want the printer mappings to be settable by all users but at the application wide level not user based...
            //i.e. we don't want every user to be required to select the same printers that everybody on this machine will be using
            //i feel like i basically get the security implications that the administrator/installer must open read/write ACL on the Program Files\{app} folder and app.config file
            //probalby because you can throw config info in those files which opens up even more access or something like that
            //anyway, i'm still going for it until i read more about it... found the following code here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/13428050-4fde-4c34-90f8-5255f4123a20/

            ConfigurationSectionGroup applicationSectionGroup = appConfig.GetSectionGroup("applicationSettings");

            applicationSettingsSection = applicationSectionGroup.Sections[ReflectionHelpers.CurrentAppName + ".Properties.Settings"] as ClientSettingsSection;
            applicationSettingsSection.SectionInformation.ForceSave = true; //crucial, otherwise just doesn't save, even though documentation indicates that it supposedly means save even if there aren't changes
            App = new SettingElementCollectionWrapper(applicationSettingsSection.Settings);
        }