Bug 20080 - System.InvalidCastException being thrown
Summary: System.InvalidCastException being thrown
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
Depends on:
Reported: 2014-05-27 23:43 UTC by Paul Johnson
Modified: 2014-07-30 19:52 UTC (History)
7 users (show)

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 GitHub or Developer Community 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:

Description Paul Johnson 2014-05-27 23:43:22 UTC
I'm getting the following error from my app (unfortunately the throwback doesn't really help, but it looks to be something to do with communications with the server). My iOS app is heavily using an Azure web service

Error message : Unable to cast object of type 'Mono.Security.Protocol.Tls.SslStreamBase+InternalAsyncResult' to type 'System.Net.WebAsyncResult'.
Source : System
Stack trace :   at System.Net.WebConnectionStream.WriteRequestAsyncCB (IAsyncResult ar) [0x00007] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:721 
  at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebAsyncResult.cs:151 

The call is coming from void WriteRequestAsyncCB in MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs - so this may be a mono error more than Xam.iOS

Using Xam.iOS Version: (Business Edition)
Comment 1 Janusz Nykiel 2014-06-03 03:12:23 UTC
Happens in Xamarin.Android as well - see https://bugzilla.xamarin.com/show_bug.cgi?id=20165 .
Comment 2 Jungmok Han 2014-06-12 15:58:22 UTC
Xamarin.iOS (Business Edition)

We also ran into the exactly same exception in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:721.  Any update on this one?
Comment 3 Infologique Innovations inc. 2014-06-12 16:24:58 UTC
Xamarin.iOS Version: (Indie Edition)

Same problem here.  Randomly crashes on 

Being critical for us because we have to wait for this fix to send app to iTunesConnect.
Comment 4 Paul Johnson 2014-06-21 17:12:27 UTC
This is working now in the current alpha and beta branches.