Configuration System failed to initialize

wallymwallym USInsider, Beta ✭✭✭

I am running in the beta channel. I just updated to V1.10 for Xamarin.iOS in Visual Studio. I am getting an error in HttpClient when I attempt to initialize an instance of the class. Given that I just updated my configuration, and this code worked before, I think the problem is in this most recent update. Does anyone else see this issue? Any idea in how to resolve? my HttpClient class is within a PCL project.

Wally

Posts

  • wallymwallym USInsider, Beta ✭✭✭

    Here is some more info. This is the InnerException from the thrown exception. The exception occurs on the line:
    HttpClient hc = new HttpClient();

    {System.TypeInitializationException: An exception was thrown by the type initializer for System.Uri ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.UriParser ---> System.TypeLoadException: Could not load type 'System.Runtime.Versioning.BinaryCompatibility' from assembly 'System'.
    --- End of inner exception stack trace ---
    at System.Uri..cctor () [0x00000] in :0
    --- End of inner exception stack trace ---
    at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00000] in :0 }
    base: {System.SystemException}
    TypeName: "System.Uri"

  • CraigDunnCraigDunn USXamarin Team Xamurai

    @wallym, does this example work? It's a very basic HttpClient inside PCL example.

  • wallymwallym USInsider, Beta ✭✭✭

    @craigdunn I am getting the exact same error within your example from GitHub.

  • I'm also seeing this error in the iOS release for Visual Studio on the beta channel - same scenario PCL using HTTPClient.

  • wallymwallym USInsider, Beta ✭✭✭
    edited December 2013

    Glad to know it's not just me. :-)

    I filed a bug on this and according to emails from bugzilla, some one found the bug. It was given a priority.

    I went back to the stable channel and it sill did not work for me. Oh well, it will eventually work again. :-)

  • wallymwallym USInsider, Beta ✭✭✭

    @lewisbinge do you still get this error if you go back to the stable channel?

  • I am getting this error too using a stable release. Any resolution to it.

  • ErikKrlErikKrl CZMember ✭✭

    I am getting this error too (using beta channel on mac and VS13) but I getting it in normal ios project. Any solution? It will help to go back to stable channel ?

  • HugoLogmans_HugoLogmans_ NLMember ✭✭✭
    edited January 2014

    Whoops, also bitten by this one. Any solution?

    System.TypeInitializationException: An exception was thrown by the type initializer for System.Uri ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.UriParser ---> System.TypeLoadException: Could not load type 'System.Runtime.Versioning.BinaryCompatibility' from assembly 'System'.

    Pff downgrading is a problem: it also want to downgrade Android, but refuses to do so, and then the VS plugin downgrade is not even started...

    Sigh sigh why on earth did I even try to upgrade :(

    PS: in XS it compiles (and runs!) fine

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited January 2014

    This sounds like this bug in XamarinVS.iOS 1.10: https://bugzilla.xamarin.com/show_bug.cgi?id=17028

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited January 2014

    Workaround:

    1. Add the attached App.config file to your Xamarin.iOS project
    2. Clean the solution.
    3. Confirm that the bin/ and obj/ folders are empty on the Windows side
    4. Confirm that the corresponding folder in ~/Library/Caches/Xamarin/mtbs is
      empty on the Mac side
    5. Build and deploy the project.
  • I'm seeing this error too. I tried your workaround Brendan and it won't work. Does this bug mean I can't use Mobile Services PCL in my Xamarin.iOS project? Any other way I can use Azure Mobile Services?

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai

    @AhmedRefaat.3781: Azure Mobile Services is a slightly different story. The NuGet package for Azure Mobile Services is not currently compatible with Xamarin because it requires .NET 4.6 PCLs, and Xamarin does not yet support those.

    But I think you might be able to use the Azure Mobile Services component instead (see for example http://stackoverflow.com/questions/20226332/how-should-i-use-azure-mobile-services-with-pcl-or-without-it-now). Just make sure to watch out for the component's "Known Issues." For example, at the moment the component does not work when referenced from a profile 78 PCL.

  • AhmedRefaatAhmedRefaat USMember

    I was already aware about the NuGet vs Xamarin Component gotcha and I tried using the Xamarin component in a PCL project and referencing that in both my Android and iOS projects. Got the same System.TypeInitializationException in both Android and iOS when I tried running Azure Mobile Client commands.

Sign In or Register to comment.