Bug 16718 - Xamarin.iOS instantiating HttpClient in PCL class
Summary: Xamarin.iOS instantiating HttpClient in PCL class
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.4.x
Hardware: PC Windows
: Normal normal
Target Milestone: Untriaged
Assignee: Alexander Köplinger [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2013-12-10 22:40 UTC by Wally McClure
Modified: 2016-12-22 16:37 UTC (History)
7 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Wally McClure 2013-12-10 22:40:31 UTC
I am running in a PCL class within Xamarin.IOS in Visual studio 2013 on Windows 8.1.  This is in the beta of Xamarin.iOS 1.10.  I start up my sample.  When I get to the line:
var hc = new HttpClient();
I get an error.  The basic error sounds very general.  The inner exception seems to have much more data.
forum post on the subject:
forums.xamarin.com/discussion/11122/configuration-system-failed-to-initialize


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"
Comment 1 Sadik Ali 2013-12-11 10:12:46 UTC
I am able to reproduce this issue,

Followed below steps to reproduce:

1. Downloaded sample app from link "https://github.com/conceptdev/xamarin-samples/tree/master/HttpClientPortable".
2. Debug android app.
3. Application deployed successfully.
4. Select Api "http - WebRequest" or "Https - WebResquest" etc and click on "Issue Http Request" button.
5. Got An unhandled exception, 

Refer screen shot "http://screencast.com/t/DkjIWdeR7120" 

Checked With:
Windows 7
Visual Studio 2010,2012, 2013
X.iOS 7.0.4-209
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2014-01-14 17:35:26 UTC
I suspect bug 17028, and maybe also bug 17190, are the same as this bug

The report for bug #17028 has a workaround:
https://bugzilla.xamarin.com/show_bug.cgi?id=17028#c1
Comment 3 Sebastien Pouliot 2016-12-22 16:37:45 UTC
The above sample has been used extensively to test the new http handlers and Apple TLS and that bug never came up. It's quite likely it was solved in the bug mentioned in comment #2.