Multiple AppSettings files, is it possible?

You can’t have more than one appsettings because that’s the name of a section. You can add a new section though that uses the same kind of section definition as appsettings. E.g., <configuration> <configSections> <section name=”DatabaseConfig” type=”System.Configuration.NameValueFileSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″/> </configSections> …. <DatabaseConfig> <add key=”Whatever” value=”stuff”/> </DatabaseConfig> </configuration>

Find current country from iPhone device

To find the country of the user’s chosen language: NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale. NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc. In Swift: let currentLocale = NSLocale.currentLocale() let countryCode = currentLocale.objectForKey(NSLocaleCountryCode) as? String If you want to find the country code of … Read more

appSettings vs applicationSettings. appSettings outdated? [duplicate]

This has been discussed before here: Pros and cons of appSettings vs applicationSettings (.NET app.config). As for your questions: The older one is <appSettings>, it was around before 2.0, <applicationSettings> became available in 2.0. Advantage? When I’m editing a value, or adding a value on a server where the best tool is notepad <applicationSettings> is … Read more

How to get values from appsettings.json in a console application using .NET Core?

Your example is mixing in some ASP NET Core approaches that expect your code to be hosted. To minimally solve the issue of getting options or settings from a JSON configuration, consider the following: A config.json file, set to “Copy to Output Directory” so that it is included with the build: { “MyFirstClass”: { “Option1”: … Read more

ASP.NET Core appsettings.json update in code

Basically you can set the values in IConfiguration like this: IConfiguration configuration = … // … configuration[“key”] = “value”; The issue there is that e.g. the JsonConfigurationProvider does not implement the saving of the configuration into the file. As you can see in the source it does not override the Set method of ConfigurationProvider. (see … Read more

What is the difference between app.config file and XYZ.settings file?

UPDATE: In ASP.NET Core Land, configuration is no longer managed via either of these – see this fantastic writeup from Travis Illig with the a-z on Microsoft.Extension.Configuration and Microsoft.Extensions.Configuration.Binder which are effectively a superset of all this Settings (Both from a .settings set and Configuration.AppSettings), are stored in the .config file [alongside lots of other … Read more

Why isn’t there an XML-serializable dictionary in .NET?

I know this has been answered before, but since I have a very concise way (code) for doing IDictionary serialization with the DataContractSerializer class (used by WCF, but could and should be used anywhere) I couldn’t resist contributing it here: public static class SerializationExtensions { public static string Serialize<T>(this T obj) { var serializer = … Read more

manual language selection in an iOS-App (iPhone and iPad)

In the meantime I did find a solution for my problem on myself: I created a new class “LocalizeHelper”: Header LocalizeHelper.h //LocalizeHelper.h #import <Foundation/Foundation.h> // some macros (optional, but makes life easy) // Use “LocalizedString(key)” the same way you would use “NSLocalizedString(key,comment)” #define LocalizedString(key) [[LocalizeHelper sharedLocalSystem] localizedStringForKey:(key)] // “language” can be (for american english): “en”, … Read more