AppSettings Reader for Xamarin and Xamarin.Forms

While each mobile platforms do offer their own settings management api, there are no built in ways to read settings from a good old .net style app.config xml file; This is due to a bunch of good reasons reasons, notably the .net framework configuration management api being on the heavyweight side, and each platform having their own file system api.

So we built a simple PCLAppConfig library nicely nuget packaged for your immediate consumption.

Add this PCL app.config file as a linked file on all your platform projects. For android, make sure to set the build action to ‘AndroidAsset’, for UWP set the build action to ‘Content’
Access your setting:

Add an app.config on your shared pcl project and ensure that Build Action:EmbeddedResource, and add your appSettings entries, as you would do with any app.config
The source code and demo app are available in github

I tried using you NuGet Package on my Xamarin.Android app and followed the above instructions to try getting it to work however the package includes a bunch of ID Updates into the Resource.Designer.cs file for a bunch of Forms resources that are not included with an Android project. This makes it so that the app con no longer be built due to the missing references and removing the reference to the package that puts them there stops the "PCLAppConfig.FileSystemStream.PortableStream.Current" from being recognised.

Do you have a NuGet Package that will work for Xamarin.Android projects?

Locate the other place you have already initialised the configuration manager.
Or maybe you are calling the same line of code more than once.
Put a breakpoint on the configuration manager initialisation code and see if it gets hit more than once.
A.

System.NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation.

I installed PCLAppConfig via Nuget; it installed the PCLStoage dependency references and the PCLAppConfig references in all 3 projects (Portable, iOS, Android).

Hi, I am facing the same issue. But i am unable to understand why would app.xaml.cs call the Initialise function twice. In debug its only calling once but on release it is sometimes crashing with this exception.

Xamarin caused by: android.runtime.JavaProxyThrowable: System.TypeInitializationException: The type initializer for 'ConfigurationManager' threw an exception. ---> System.InvalidOperationException: Initialise must be called once in program

Hello:
I use the PCLAppConfig library to read the config file and it shows me. Now I would like to know what I have to do to be able to modify it in execution, since my file saves the configuration of different objects. That through their reading I show them on screen.
Thank you

I didn't found any solution, i gave up and use the Application.Current.Properties

The Application subclass has a static Properties dictionary which can be used to store data, in particular for use in the OnStart, OnSleep, and OnResume methods. This can be accessed from anywhere in your Xamarin.Forms code using Application.Current.Properties.