In monodroid or monotouch what should I use instead of app.config for configuration strings?
app-config, mono, xamarin.android, xamarin.ios
Solution
You should just use a static class with `#if` declarations.
Something like:
public static class Configuration {
#if DEBUG
public const string ConnectionString = "debug string";
#else
public const string ConnectionString = "release string";
#endif
}
The benefit to using `app.config` is the ability to change these settings on the file system without recompiling. On mobile, there isn't a good way (especially on iOS) to edit the file after it's deployed. So it's generally better to just use a static class and redeploy when you need to change the values. This will also work on all platforms, because it is just C# code doing the work.
Problem
I want to store development vs production connection strings and configuration strings in a monodroid project. I would normally store it as app settings in a web.config or an app.config, but how should I do it in monodroid and monotouch projects? I would also like for it to switch configurations automatically between debug and release builds just as visual studio does with *.config files. In an iOS app I could store these in a plist but I'd like a cross platform solution in mono. How would I do this in monodroid or monotouch?