app.config in .Net3.5

I'm not able to write to the App.conf in .Net3.5.

According to this question it goes like in .Net2.0, but it doesn't work. I can read from the config like this:

var connStr = ConfigurationManager.ConnectionStrings[ApplicationConstants.CisConnectionStringName].ConnectionString

But it's impossible for me to write in that file, because the compiler says it's not possible because of the security level.

I googled for several hours but found no solution. I hope you can help.

Thx

Edit:

I tried different Ways:

ConfigurationManager.ConnectionStrings[ApplicationConstants.CisConnectionStringName].ConnectionString = "string";

also...

 Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
NetSectionGroup netSectionGroup = config.GetSectionGroup("system.net") as NetSectionGroup;
netSectionGroup.Settings.HttpWebRequest.UseUnsafeHeaderParsing = true;                      
config.SaveAs(@"C:\ProgramData\test.config", ConfigurationSaveMode.Full);

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"C:\ProgramData\test.config");

also...

string exePath = System.Reflection.Assembly.GetEntryAssembly().CodeBase.Substring(0, System.Reflection.Assembly.GetEntryAssembly().CodeBase.LastIndexOf('/'));
        var configuration = ConfigurationManager.OpenExeConfiguration(exePath);
...

(Examples not valid for the given Path, as I tested it they where ;-))

But nothing worked. The config file is in the same directory as the .exe (currently "C:\Users\MyUser\SVN\CIS\Assemblies")

Answers


This worked for me:

 System.Configuration.Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

        config.AppSettings.Settings["oldPlace"].Value = "3";     
        config.Save(ConfigurationSaveMode.Modified);
        ConfigurationManager.RefreshSection("appSettings");

Need Your Help

LED Screen recognition in image using MATLAB

matlab image-processing image-recognition

I'm trying to detect the screen border from the image (In need the 4 corners).

mahout taste: in-memory DataModel that supports set/removePreference

mahout recommendation-engine

I could not find an in-memory DataModel that supports setPreference / removePreference / refresh. Instead, they all "recreate" a new GenericDataModel anytime one adds or remove preferences. Am I mi...