{"id":4309,"date":"2014-03-30T09:47:08","date_gmt":"2014-03-30T09:47:08","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-system-configuration-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:47:08","modified_gmt":"2014-03-30T09:47:08","slug":"problem-about-system-configuration-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-system-configuration-collection-of-common-programming-errors\/","title":{"rendered":"problem about system.configuration-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/040056e71103d9721f0b7b606fd3d681?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\niammichael<br \/>\nc# .net multithreading system.configuration<br \/>\nIs there an easy method of accessing custom System.Configuration-based configuration data through a thread-safe interface without requiring each execution context from loading\/reloading configuration information which would be computationally burdensome?System.Configuration classes, like most (all?) other classes in Microsoft&#8217;s .Net library documentation, are annotated with the following thread-safety information:Any public static (Shared in Visual Basic) members of this type are thread safe. An<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/36896e070359e760e891389ace90dc40?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngyurisc<br \/>\n.net configurationsection system.configuration<br \/>\nI need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface public interface IPreferencesBackend {bool TryGet&lt;T&gt;(string key, out T value);bool TrySet&lt;T&gt;(string key, T value); }At runtime, I can say something like: My.Foo.Data data = new My.Foo.Data(&#8220;blabla&#8221;); Pref pref =<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6c3935e8e58cdd1c3c970c54d81d6688?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJohn<br \/>\nasp.net encryption web-config aspnet-regiis.exe system.configuration<br \/>\nI have a web application with a custom configuration section. That section contains information I&#8217;ld like to encrypt (was hoping to use ASPNet_RegIIS rather than do it myself).Web.Config:&lt;?xml version=&#8221;1.0&#8243;?&gt;&lt;configuration xmlns=&#8221;http:\/\/schemas.microsoft.com\/.NetConfiguration\/v2.0&#8243;&gt;&lt;configSections&gt;&lt;section name=&#8221;MyCustomSection&#8221; type=&#8221;MyNamespace.MyCustomSectionHandler, MyAssembly&#8221;\/&gt;&lt;\/configSections&gt; &lt;configProtectedData&gt;&lt;providers&gt;&lt;clear \/&gt;&lt;ad<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9da2ca6abf3a1e28fb470f2b3ae2c34?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nabatishchev<br \/>\nc# app-config configurationsection system.configuration xml-formatting<br \/>\nI have custom ConfigurationSection and call Configuration.Save() after some modifications against it:var config = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap() { ExeConfigFilename = &#8220;My.config&#8221; },ConfigurationUserLevel.None); if (config != null) {\/\/ do stuffconfig.Save(); }Currently it performs some formatting of resulting XML. For example, replaces tabs with spaces, inserts line-breaks if it thinks that it&#8217;s too long (&gt; ~130 characters), etc.How can I preserve or<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f417add1e174a48b7e233db781dc02ef?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nhwiechers<br \/>\nc# .net system.configuration<br \/>\nLet&#8217;s say I have a configuration property that looks like this. Note that there is no default value.[ConfigurationProperty(&#8220;x&#8221;, IsRequired = true)] [StringValidator(MinLength = 1)] public string X {get { return (string)this[&#8220;x&#8221;]; }set { this[&#8220;x&#8221;] = value; } }Now I add my section like this:&lt;mySection x=&#8221;123&#8243; \/&gt;I&#8217;ll get this error:The value for the property &#8216;x&#8217; is notvalid. The error is: The string mustbe at least 1 characters long.It works if I change the configuration property to include a<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>iammichael c# .net multithreading system.configuration Is there an easy method of accessing custom System.Configuration-based configuration data through a thread-safe interface without requiring each execution context from loading\/reloading configuration information which would be computationally burdensome?System.Configuration classes, like most (all?) other classes in Microsoft&#8217;s .Net library documentation, are annotated with the following thread-safety information:Any public static (Shared [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4309","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4309"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4309\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}