How do I set CultureInfo.CurrentCulture from an App.Config file?

I don’t know a built-in way to set it from App.config, but you could just define a key in your App.config like this <configuration> <appSettings> <add key=”DefaultCulture” value=”pt-BR” /> </appSettings> </configuration> and in your application read that value and set the culture CultureInfo culture = new CultureInfo(ConfigurationManager.AppSettings[“DefaultCulture”]); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; Also, as … Read more

Enabling Intellisense for Custom Sections in .config Files

As the other answers say, you need to provide an XML Schema document for your custom configuration section. There’s no need to add the .xsd schema file to some global directory; you can reference it directly from your custom section in the App.config file: <configuration> <!– make the custom section known to .NET’s configuration manager … Read more

How to write an URI string in App.Config

You haven’t properly encoded the ampersands in your URI. Remember that app.config is an XML file, so you must conform to XML’s requirements for escaping (e.g. & should be &amp;, < should be &lt; and > should be &gt;). In your case, it should look like this: <appSettings> <add key=”fooUriString” value=”https://foo.bar.baz/download/DownloadStream?id=5486cfb8c50c9f9a2c1bc43daf7ddeed&amp;login=null&amp;password=null” /> </appSettings> But in … Read more

Use XML includes or config references in app.config to include other config files’ settings

Yes, you can use the configSource attribute of the configuration block. All configuration blocks have this attribute – although it isn’t documented. See this article, all the way at the bottom, appendix B. I’ve also pasted the relevant section below: Appendix B: including external configuration files Despite all the greatness to be found in .NET … Read more

sub appsettings in the appsetting node c#

You can add custom sections in app.config without writing additional code. All you have to do is “declaring” new section in configSections node like that <configSections> <section name=”genericAppSettings” type=”System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” /> </configSections> and then you can define this section filling it with keys and values: <genericAppSettings> <add key=”testkey” value=”generic” /> <add key=”another” … Read more

Reading keyvalue pairs into dictionary from app.config configSection

using ConfigurationManager class you can get whole section from app.config file as Hashtable which you can convert to Dictionary if you want to: var section = (ConfigurationManager.GetSection(“DeviceSettings/MajorCommands”) as System.Collections.Hashtable) .Cast<System.Collections.DictionaryEntry>() .ToDictionary(n=>n.Key.ToString(), n=>n.Value.ToString()); you’ll need to add reference to System.Configuration assembly

App.Config change value

AppSettings.Set does not persist the changes to your configuration file. It just changes it in memory. If you put a breakpoint on System.Configuration.ConfigurationManager.AppSettings.Set(“lang”, lang);, and add a watch for System.Configuration.ConfigurationManager.AppSettings[0] you will see it change from “English” to “Russian” when that line of code runs. The following code (used in a console application) will persist … Read more

How to programmatically modify WCF app.config endpoint address setting?

Is this on the client side of things?? If so, you need to create an instance of WsHttpBinding, and an EndpointAddress, and then pass those two to the proxy client constructor that takes these two as parameters. // using System.ServiceModel; WSHttpBinding binding = new WSHttpBinding(); EndpointAddress endpoint = new EndpointAddress(new Uri(“http://localhost:9000/MyService”)); MyServiceClient client = new … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)