Bug 20165 - Cannot cast from source type to destination type at System.Net.WebConnectionStream.WriteRequestAsyncCB
Summary: Cannot cast from source type to destination type at System.Net.WebConnectionS...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.10.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-05-29 15:22 UTC by Allie Miller
Modified: 2014-07-02 11:52 UTC (History)
20 users (show)

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


Attachments
Exception Examples (22.11 KB, text/plain)
2014-06-04 11:18 UTC, Jason Couture
Details


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 FIXED

Description Allie Miller 2014-05-29 15:22:11 UTC
*Reported on behalf of a user*

Similar to Bug #18944

*Observed Behavior*
After updating to the latest version of the software (listed below), the user reported getting "random" Casting errors when accessing their web services. 

*The Error*
Cannot cast from source type to destination type." String

StackTrace " at System.Net.WebConnectionStream.WriteRequestAsyncCB (IAsyncResult ar) [0x00000] in <filename unk..." string

*Additional Information*
The build log and logs from VS are attached to this report.


*Version Information*
Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Professional

LightSwitch for Visual Studio 2012   04938-088-0069382-02694
Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools   04938-088-0069382-02694
Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012   04938-088-0069382-02694
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012   04938-088-0069382-02694
Microsoft Visual Basic 2012

Visual C# 2012   04938-088-0069382-02694
Microsoft Visual C# 2012

Visual C++ 2012   04938-088-0069382-02694
Microsoft Visual C++ 2012

Visual F# 2012   04938-088-0069382-02694
Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker   04938-088-0069382-02694
MicrosoftÆ Visual StudioÆ 2012 Code Analysis Spell Checker

Portions of International CorrectSpellô spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American HeritageÆ Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools   04938-088-0069382-02694
Microsoft Visual Studio 2012 SharePoint Developer Tools

ASP.NET and Web Tools   2012.3.41009
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Windows Azure Web Sites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure

Common Azure Tools   1.0
Provides common services for use by Azure Mobile Services and Windows Azure Tools.

Crystal Reports for .NET Framework   
Crystal Reports for .NET Framework


NuGet Package Manager   2.7.40911.225
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   11.1.20905.0
Microsoft SQL Server Data Tools

VSTools   1.0
To allow publishing to our custom auto update server

Windows Azure Tools   2.1
Windows Azure Tools for Microsoft Visual Studio 2012 - v2.1.10716.1601

Xamarin   3.0.54.0 (d3cf238e3845e930e312b6ec9b4c6c5437c33067)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android

Xamarin.Android   4.12.4.20 (b5dc5ce91305e19de51d71a1122c109719c4bc34)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   3.0.54.0 (d3cf238e3845e930e312b6ec9b4c6c5437c33067)
Visual Studio extension to enable development for Xamarin.iOS
Comment 3 mlpstingray 2014-06-02 16:18:45 UTC
Would you guys have an idea about the fix time frame of this issue? This is major for us. Thanks in advance.
Comment 4 Jonathan Pryor 2014-06-02 16:53:16 UTC
I'm confused.

Attachment #6913 [details] is the build output, which (1) shows no errors in deployment or installation, and (2) doesn't mention an InvalidCastException.

Attachment #6914 [details] is the devenv log, which _does_ show an InvalidCastException, but doesn't provide a stack trace.

Neither attachment mentions System.Net.WebConnectionStream.WriteRequestAsyncCB().

If I'm reading and understanding this properly, the InvalidCastException is coming from the web service. Is this correct?

Assuming I understand this correctly, my best guess is that we've somehow changed what we write to the network so that the server-side code is no longer able to interpret it.

Assuming the above, we would need a test case. We need to know _what_ we're generating wrong, and what it should be.
Comment 5 Janusz Nykiel 2014-06-03 03:10:56 UTC
I am hitting this error using one specific device (Xperia T, stock, updated). I am doing an async HTTPS POST request via HttpClient API. It is _not_ "thrown" by the service. The exception is thrown in a thread pool thread and its stack trace is:

>	0xD in System.Net.WebConnectionStream.WriteRequestAsyncCB	C#
 	0x7 in System.Net.WebAsyncResult.CB	C#

There is another thread pool thread at the time the exception is thrown, its stack trace is:

>	0x0 in System.Net.Sockets.Socket.Worker.DispatcherCB	C#

There is only one thread with Mono stack trace:

>	0x30 in System.Threading.WaitHandle.WaitOne_internal	C#
 	0x40 in System.Threading.WaitHandle.WaitOne	C#
 	0x3 in System.Threading.WaitHandle.WaitOne	C#
 	0x25D in System.Threading.Timer.Scheduler.SchedulerThread	C#
 	0x21 in System.Threading.Thread.StartInternal	C#

This started happening after an upgrade from Xamarin.Android 4.12.1 to 4.12.4 - I'm seeing some HTTP related fixes in the release notes.
Comment 6 Janusz Nykiel 2014-06-03 03:13:06 UTC
Happens in Xamarin.iOS as well - https://bugzilla.xamarin.com/show_bug.cgi?id=20080 .
Comment 7 Paul Johnson 2014-06-03 03:38:22 UTC
My one is coming from using Azure which also goes across https - we really can't submit to Apple with this bug in the code as they could test and it goes bang for no reason and we have the app declined...
Comment 8 mlpstingray 2014-06-03 08:29:52 UTC
Hello John,

I cannot double check the attachment since they seems to be private.

What I had is something like below that was taken from the debug console in VS. 

05-30 10:27:00.085 E/mono    (16497): 
05-30 10:27:00.085 E/mono    (16497): Unhandled Exception:
05-30 10:27:00.085 E/mono    (16497): System.InvalidCastException: Cannot cast from source type to destination type.
05-30 10:27:00.085 E/mono    (16497):   at System.Net.WebConnectionStream.WriteRequestAsyncCB (IAsyncResult ar) [0x00000] in <filename unknown>:0 
05-30 10:27:00.085 E/mono    (16497):   at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in <filename unknown>:0 
05-30 10:27:00.120 F/        (16497): * Assertion at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/mono/mono/io-layer/wthreads.c:108, condition `ok' not met
05-30 10:27:00.120 E/mono-rt (16497): Stacktrace:
05-30 10:27:00.120 E/mono-rt (16497): 
05-30 10:27:00.120 E/mono-rt (16497):   at <unknown> <0xffffffff>
05-30 10:27:00.120 E/mono-rt (16497):   at (wrapper managed-to-native) System.Threading.Monitor.try_enter_with_atomic_var (object,int,bool&) <IL 0x00023, 0xffffffff>
05-30 10:27:00.120 E/mono-rt (16497):   at System.Threading.Monitor.TryEnter (object,int,bool&) <IL 0x00044, 0x0017f>
05-30 10:27:00.120 E/mono-rt (16497):   at System.Threading.Monitor.Enter (object,bool&) <IL 0x00003, 0x0004f>
05-30 10:27:00.120 E/mono-rt (16497):   at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus,System.Exception,string) <IL 0x0000e, 0x000d3>
05-30 10:27:00.120 E/mono-rt (16497):   at System.Net.WebConnection.ReadDone (System.IAsyncResult) <IL 0x0005e, 0x00387>
05-30 10:27:00.120 E/mono-rt (16497):   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <IL 0x00052, 0xffffffff>
05-30 10:27:00.120 E/mono-rt (16497): 
05-30 10:27:00.120 E/mono-rt (16497): =================================================================
05-30 10:27:00.120 E/mono-rt (16497): Got a SIGSEGV while executing native code. This usually indicates
05-30 10:27:00.120 E/mono-rt (16497): a fatal error in the mono runtime or one of the native libraries 
05-30 10:27:00.120 E/mono-rt (16497): used by your application.
05-30 10:27:00.120 E/mono-rt (16497): =================================================================
05-30 10:27:00.120 E/mono-rt (16497): 
05-30 10:27:00.130 F/        (16497): * Assertion at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/mono/mono/io-layer/wthreads.c:108, condition `ok' not met
The program 'Mono' has exited with code 0 (0x0).

This happens for us when we make a lot of request with the same WebClient. 

I hoped that I didn't need to provide a test case since I saw a similar error on iOS, but I understand that it makes it harder to debug. 

I will try to create a test case and see if it isolates the bug properly.

In the mean time, if you find a solution, let me know.
Comment 10 mlpstingray 2014-06-03 14:17:55 UTC
I'm having hard time to reproduce the bug in a separate test-bed, it seems to be pretty random and occurs often when two or three calls are made within a very short period of time (5 or 10 ms). I'll update again as soon as I find something.

It would be awesome if you guys could find it before me...
Comment 11 mlpstingray 2014-06-03 14:55:38 UTC
I am unable to reproduce the problem in a separate test case (which is probably
too simple to reproduce the bug), the only thing that I manage to get is the
following error : https://bugzilla.xamarin.com/show_bug.cgi?id=20316

I wish I could have helped more, but we are releasing in least than a month now
and I cannot spend more time on this issue. We will have to release with the
previous version of Xamarin Android, before 3.0.
Comment 12 Jonathan Pryor 2014-06-03 15:02:06 UTC
This is by far the most important piece of information, and sadly didn't appear until Comment #8:

> 05-30 10:27:00.120 F/        (16497): * Assertion at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/mono/mono/io-layer/wthreads.c:108, condition `ok' not met

This corresponds to:

https://github.com/mono/mono/blob/9de8c08d26f8d17ec3f19386b3baf92d358b6010/mono/io-layer/wthreads.c#L108

	g_assert (ok);

which looks rather "bad"...

Unfortunately the above doesn't appear in Comment #9 nor Comment #5...

Friendly reminder: if you prefix lines with "> ", bugzilla won't line-wrap, making the entires much easier to read.
Comment 13 mlpstingray 2014-06-03 15:20:01 UTC
Sorry about the missing information, I am not sure what was posted as previous stack trace info, since I do not have access to it.

Apologize also for the " > " prefix, I was wondering how could I enter code in BugZilla, I will do next time.

Finally, the line below was actually appearing on the very first Stack Trace that I got the InvalidCastException (the one I printed in comment #8). 

> 05-30 10:27:00.120 F/        (16497): * Assertion at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/mono/mono/io-layer/wthreads.c:108, condition `ok' not met

However, it does not seems to be printed out every time, not sure why.
Comment 14 Jonathan Pryor 2014-06-03 15:37:00 UTC
@Janusz: Regarding Comment #5 and Comment #6, Xamarin.Android 4.12.4 contains a mono bump in order to fix a variety of _other_ failures in the HTTP stack; see the Integrated Mono features/fixes section at:

http://developer.xamarin.com/releases/android/xamarin.android_4/xamarin.android_4.12/#4

This should also contain fixes for Bug #15135, which isn't listed in the above (apparently because mono mono commit specifically mentioned #15135...).
Comment 15 Jonathan Pryor 2014-06-03 15:37:51 UTC
@mipstingray: Would it be possible for you to create a self-contained repro so that we can debug this locally?
Comment 18 Lars 2014-06-04 02:55:15 UTC
Im having this problem aswell. I could send you src if you need to have a test case. Where should i send it to?
Comment 19 mlpstingray 2014-06-04 08:21:08 UTC
@Lars that'd be awesome if you manage to create a test case. You only have to use the "Add An Attachment" link which is located before the first comment. 

Then you just have to select your src or your zip. You can even make it private to other users if you wish.
Comment 21 Vlad Cirstea 2014-06-04 09:01:42 UTC
Hi, it is worth mentioning that, at least for me, this happens on android 4.1.2 devices. I’ve also tested on 4.4.2 and it seems to be working fine. I’ve attached a test project.
Comment 22 Jason Couture 2014-06-04 10:34:38 UTC
Ive had this issue with android 4.4.2 and 4.4.3:
It seems to switch between SIGABRT and SIGSEGV, there is no reliable way that I have found to trigger this issue.

>E/mono    ( 3999):
>E/mono    ( 3999): Unhandled Exception:
>E/mono    ( 3999): System.InvalidCastException: Cannot cast from source type to destination type.
>E/mono    ( 3999):   at System.Net.WebConnectionStream.WriteRequestAsyncCB (IAsyncResult ar) [0x00000] in <filename unknown>:0
>E/mono    ( 3999):   at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in <filename unknown>:0
>F/libc    ( 3999): bionic/libstdc++/src/pure_virtual.cpp:6: void __cxa_pure_virtual(): assertion "!"Pure virtual function called. Are you calling virtual methods from a destructor?"" failed
>E/mono-rt ( 3999): Stacktrace:
>E/mono-rt ( 3999):
>E/mono-rt ( 3999):   at <unknown> <0xffffffff>
>E/mono-rt ( 3999):   at (wrapper managed-to-native) object.wrapper_native_0x41505687 (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
>E/mono-rt ( 3999):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
>E/mono-rt ( 3999):   at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) <0x00097>
>E/mono-rt ( 3999):   at Android.Widget.TextView.set_TextFormatted (Java.Lang.ICharSequence) <0x000f7>
>E/mono-rt ( 3999):   at Android.Widget.TextView.set_Text (string) <0x0004f>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Droid.Target.MvxTextViewTextTargetBinding.SetValueImpl (object,object) <0x00077>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.Target.MvxConvertingTargetBinding.SetValue (object) <0x0019f>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (object) <0x0008f>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.<CreateSourceBinding>b__0 (object,System.EventArgs) <0x0003b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxSourceStep.SendSourcePropertyChanged () <0x0003b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxPathSourceStep.SourceBindingOnChanged (object,System.EventArgs) <0x0001b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourceBinding.FireChanged () <0x0003b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.Source.Chained.MvxChainedSourceBinding.ChildSourceBindingChanged (object,System.EventArgs) <0x0001b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourceBinding.FireChanged () <0x0003b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.Source.Chained.MvxChainedSourceBinding.OnBoundPropertyChanged () <0x0001b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding.SourcePropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <0x0007b>
>E/mono-rt ( 3999):   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) <0xffffffff>
>E/mono-rt ( 3999):   at <unknown> <0xffffffff>
>E/mono-rt ( 3999):   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
>E/mono-rt ( 3999):   at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x000cf>
>E/mono-rt ( 3999):   at System.Reflection.MethodBase.Invoke (object,object[]) <0x00047>
>E/mono-rt ( 3999):   at Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription`2.OnSourceEvent (object,TEventArgs) <0x000a3>
>E/mono-rt ( 3999):   at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <0x0009b>
>E/mono-rt ( 3999):   at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <0x0009b>
>E/mono-rt ( 3999):   at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <0x0009b>
>E/mono-rt ( 3999):   at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <0x0009b>
>E/mono-rt ( 3999):   at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <0xffffffff>
>E/mono-rt ( 3999):   at PSS.Shared.Models.Configuration.Terminal.NotifyPropertyChangedBase.SafePropertyChanged (string) <0x0009f>
>E/mono-rt ( 3999):   at PSS.Shared.Models.Configuration.Terminal.TerminalCore.DumpPropertyChanged () <0x0023b>
>E/mono-rt ( 3999):   at PSS.Shared.Models.Configuration.Terminal.TerminalCore.RunMainThreadQueue () <0x0011f>
>E/mono-rt ( 3999):   at PSS.Terminal.Droid.Platform.AndroidMainThreadInvoker/<>c__DisplayClass3.<Invoke>b__1 () <0x0004b>
>E/mono-rt ( 3999):   at Cirrious.CrossCore.Core.MvxMainThreadDispatcher.ExceptionMaskedAction (System.Action) <0x0002b>
>E/mono-rt ( 3999):   at Cirrious.MvvmCross.Droid.Views.MvxAndroidMainThreadDispatcher/<>c__DisplayClass1.<RequestMainThreadAction>b__0 (object) <0x0001b>
>E/mono-rt ( 3999):   at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () <0x00027>
>E/mono-rt ( 3999):   at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
>E/mono-rt ( 3999):   at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>
>E/mono-rt ( 3999):   at (wrapper dynamic-method) object.59f45e82-270c-4c58-8014-1bb99672ac20 (intptr,intptr) <0x0003b>
>E/mono-rt ( 3999):   at (wrapper native-to-managed) object.59f45e82-270c-4c58-8014-1bb99672ac20 (intptr,intptr) <0xffffffff>
>E/mono-rt ( 3999):
>E/mono-rt ( 3999): =================================================================
>E/mono-rt ( 3999): Got a SIGABRT while executing native code. This usually indicates
>E/mono-rt ( 3999): a fatal error in the mono runtime or one of the native libraries
>E/mono-rt ( 3999): used by your application.
>E/mono-rt ( 3999): =================================================================
>E/mono-rt ( 3999):
Comment 23 Jason Couture 2014-06-04 11:18:29 UTC
Created attachment 6978 [details]
Exception Examples

Here's a collection of examples that I was able to collect in about 5 minutes. This product was perfectly stable prior to the 3.0 update.
Comment 24 Jonathan Pryor 2014-06-04 12:08:19 UTC
We believe that this should be fixed in the forthcoming Xamari.Android 4.14.0 release.
Comment 26 mlpstingray 2014-06-04 12:10:18 UTC
Awesome news! Do you have an idea what is the time frame for the next Xamarin Release?
Comment 27 Jonathan Pryor 2014-06-04 12:31:27 UTC
@mlpstingray: Every time I attempt to make an estimate, I wind up being horrifically wrong. Some year I'll realize that the only answer to this question is no answer at all.

^H^H^H^H I mean, 4.14 will be out as soon as we're able to get it out. ;-)
Comment 28 mlpstingray 2014-06-04 13:03:24 UTC
@jonp Hahaha, you're right! We won't release with this version anyway since we cannot ship a crash like that. Thanks anyway! Regards
Comment 29 ErikCrave 2014-06-05 03:30:00 UTC
Any chance that there will at least be a beta or an alpha release with this fixed any time soon? We are having this issue as well and would like to know if this really is fixed or we will have to start looking for ways to work around it.
Comment 30 Jason Couture 2014-06-05 08:08:52 UTC
@ErkiCrave

Thanks to Allie, I have these instructions to downgrade back to the previous version (Thank you again Allie!), Hopefully you find this helpful:

>In the meantime, if you'd like to downgrade back to the previous version of the software, you may do so using the below steps:

>1) Uninstall the Xamarin plugins, and if you have it, Xamarin Studio via Add/Remove Programs

>2) Open the registry editor (regedit)

>3) Look for this key:

>HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\SharedDlls

>4) Find all the entries that match this pattern:

>C:\Program Files*\Microsoft Visual Studio 1*.0\Common7\IDE\Extensions\Xamarin

>5) Remove the entires from above.

>6) Navigate to your Visual Studio directory and delete the Xamarin folder

>C:\Program Files*\Microsoft Visual Studio 1*.0\Common7\IDE\Extensions\Xamarin

>1*.0 is the VS version where 12.0 = VS2013, 11.0 = VS2012 and 10.0 = VS2010.

>7) Please delete the following additional directories:
>%LOCALAPPDATA%\Xamarin\
>%PROGRAMDATA%\Mono for Android
>%PROGRAMDATA%\MonoTouch

>8) Please install the following manual downgrade files:
It looks like a manual installation would get everything installed properly. Please download and install the packages shown below in the order listed:

>1.*OPTIONAL IF YOU ARE USING VISUAL STUDIO*
Xamarin Studio: http://download.xamarin.com/studio/Windows/XamarinStudio-5.0.0.878-0.msi

>2. Xamarin.Android for Windows:
http://download.xamarin.com/MonoforAndroid/Windows/mono-android-4.12.03003_signed.msi

>3. Xamarin.iOS for VS:
http://download.xamarin.com/MonoTouchforVisualStudio/Windows/Xamarin.iOS_Setup-1.10.47.0.msi
Comment 31 ErikCrave 2014-06-05 08:12:35 UTC
Thanks for sharing, Jason! That does help.
Comment 32 Paul Johnson 2014-06-06 07:48:25 UTC
Will there be a similar fix for Xam.iOS in the pipeline too? I've had the same app rejected 3 times now by Apple because of the random crash this is causing
Comment 33 Zeno Foltin 2014-06-06 09:30:44 UTC
We run into this issue too on Android. Downgrading to Xamarin.Android 4.12.3 is our current workaround to it. Having the fix in the Alpha or Beta channel would be awesome, this must be pretty much a showstopper for everyone using any kind of webrequest in their app.
Comment 34 Dmitry Skorinko 2014-06-08 11:05:03 UTC
See this error on both platforms after upgrading to Xamarin.iOS 7.2.3.39 and Xamarin.Android 4.12.4
The same bug: https://bugzilla.xamarin.com/show_bug.cgi?id=18944
Comment 35 Ahmad Awada 2014-06-11 03:51:36 UTC
i have the same problem i have been looking into my code for one week to know what is the error "and finally it is xamarin" it occur when i call a webservice and not from the first time after the third or fourth time and it is occur on some devices i have been testing on note 2 with android 4.4.2. now i downgraded into android 4.12.3 until the problem is solved. thanks for sharing, Jason.
Comment 36 Connor 2014-06-13 14:34:47 UTC
Any status on when we might see a fix for this? My app is basically useless with the bug.
Comment 37 mlpstingray 2014-06-13 14:38:12 UTC
@Connor Read comment 27 again : https://bugzilla.xamarin.com/show_bug.cgi?id=20165#c27
Comment 38 Connor 2014-06-13 14:51:28 UTC
Well the status is still NEEDINFO and I'd like to know if it's going to be fixed in a couple weeks or in a couple months. I guess I'll assume months and downgrade everything.
Comment 39 mlpstingray 2014-06-13 14:54:46 UTC
@Connor Read comment 24 : https://bugzilla.xamarin.com/show_bug.cgi?id=20165#c24

It will be fixed in the next release, the only thing you can do is downgrade to the previous 3.0 version if you have to release your app soon or if you can`t wait until the next update. 

That`s what we had to do, there is no other known workaround.
Comment 40 Connor 2014-06-13 15:55:49 UTC
I've managed to fix it by implementing ModernHttpClient (https://github.com/paulcbetts/ModernHttpClient) which allows an easy drop in replacement for HttpClient.
Comment 41 Zeno Foltin 2014-06-16 13:15:28 UTC
The latest alpha Xamarin.Android (4.14.0) seems to resolve this issue, although now I'm experiencing a few other issues: release apk size doubled, app gets backgrounded or possibly crashing for some other reason, Xamarin Studio had problems opening the project... none of which can be easily reproduced/reported
Comment 42 mlpstingray 2014-06-16 13:19:03 UTC
@Zeno Foltin Those issues should be addressed separatly in a different bug report. For the APK size, you should have a look to the arm/armeabi/x86 settings, maybe they got enabled again.
Comment 43 Zeno Foltin 2014-06-16 13:55:59 UTC
Thanks @mlpstingray. Not sure the apk size increase (12 megs -> 23 megs) is a bug that needs reporting. The AndroidSupportedAbis settings has not changed, got all selected, the only change that happened is the Xamarin.Android update. Not really an issue for me - building enterprise apps.
The other two issues I couldn't really reproduce / report, sorry for mentioning them here.
Comment 44 mlpstingray 2014-06-16 13:57:58 UTC
@Zeno Foltin No problem sir, if it ever happen again, you could try your luck on the Forum, sometimes other people can tell you what's wrong and it may save you some time.
Comment 45 PJ 2014-06-17 15:43:51 UTC
This issue has been resolved in our latest releases to the Beta channel. The Xamarin.Android 4.14.0 release will also contain this fix, but that release will not be stabilized until July.

The following releases contain the fix, and are based off of our current stable releases:

Xamarin.iOS 7.2.4
Xamarin.Android 4.12.5
Xamarin 3.0.56 (includes Xamarin.Android 4.12.5)
Mono 3.4.0.214
Comment 46 Jonathan Pryor 2014-07-02 11:52:02 UTC
@Zeno from Comment #43:

> Not sure the apk size increase (12 megs -> 23 megs) is a bug that needs reporting.

It would have been worth reporting, but this has since been fixed and will be in a forthcoming 4.14 alpha (perhaps the current one?).