Bug 15883 - Error getting response stream in Android 4.3
Summary: Error getting response stream in Android 4.3
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.6.x
Hardware: PC Mac OS
: High blocker
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-11-01 15:56 UTC by Allie Miller
Modified: 2017-07-12 21:51 UTC (History)
9 users (show)

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


Attachments
Logcat from Case #50155 (35.60 KB, text/plain)
2013-11-01 15:56 UTC, Allie Miller
Details
Device Deployment logs from Case #50155 (66.14 KB, application/octet-stream)
2013-11-04 10:23 UTC, Allie Miller
Details
Gref Log (666.74 KB, text/plain)
2013-11-08 15:32 UTC, Sohail Amir
Details
Mono 4.10.1 Error (36.80 KB, image/png)
2013-12-05 09:06 UTC, Sohail Amir
Details
Contents of Xamarin Folder (3.62 MB, application/x-zip-compressed)
2013-12-10 12:32 UTC, Sohail Amir
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 2013-11-01 15:56:04 UTC
Created attachment 5314 [details]
Logcat from Case #50155

When deploying to a Samsung Galaxy Note 3 (Android 4.3) device, the attached test project fails with the following error message:
"Error getting response stream (Write: The authentication or decryption has failed)"

Project deploys successfully on Android 4.2 devices.

Unable to update to 4.8.x series because the third party tool that is being utilized (MobileForms Toolkit from Resco) currently does not support 4.8.x

Logcat attached to this report

Versioning Information:
Visual Studio 2010
Xamarin.Android 4.6.8
Comment 5 Allie Miller 2013-11-04 10:23:18 UTC
Created attachment 5325 [details]
Device Deployment logs from Case #50155
Comment 7 Peter Collins 2013-11-04 14:14:43 UTC
Resolving as per Comment 6.
Comment 8 Sohail Amir 2013-11-06 11:00:24 UTC
FYI – We ran into problems with Resco controls and had to roll back to Mono 4.6. So essentially we are back to square one and will appreciate help in this regard and request you to reopen this bug. Thanks
Comment 9 Jonathan Pryor 2013-11-06 11:27:13 UTC
Xamarin.Android 4.6 predates Android v4.3 support and is no longer actively maintained; all current development is taking place on Xamarin.Android 4.10.x. There is also at least one known issue with Android v4.3 and TImeZone support that wasn't fixed until Xamarin.Android 4.8.1. (I don't know if your app uses TimeZoneInfo, but if it does you'll run into it.)

What problems are you hitting with Resco controls? It may be easier to fix those issues than to figure out how to make Xamarin.Android 4.6 work on recent Android versions.
Comment 10 Peter Collins 2013-11-06 12:01:44 UTC
As JonP says in comment 9, we'll need a little bit more info about your project. Do you have a buildable test case that demonstrates the issue by any chance?
Comment 12 Sohail Amir 2013-11-06 15:06:15 UTC
I already sent a test project several days ago to support. Anyway you can download it from:

http://www.goldcrm2.com/Downloads/Files/AndroidApplication1.zip
Comment 13 Peter Collins 2013-11-06 15:20:17 UTC
Sohail Amir, I think it would be helpful to get a test case for the issues with Resco controls that are now manifesting after updating Xamarin.Android. The original issue (shown in the first test case) is resolved in more recent versions of XA, and "It may be easier to fix those issues (w/ Resco controls) than to figure out how to make Xamarin.Android 4.6 work on recent Android versions."
Comment 14 Sohail Amir 2013-11-07 09:06:30 UTC
We got a build of their toolkit from Resco that supports Mono 4.8. Then we upgraded to Mono 4.8.1 and built our application. The error that we were seeing earlier was fixed. However, now we are getting another error that crashes the application. The stack trace from LogCat is give below. It looks like some kind of issue with Mono libraries.

11-07 08:43:27.186: E/mono-rt(10976): Stacktrace:
11-07 08:43:27.186: E/mono-rt(10976):   at <unknown> <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper managed-to-native) object.wrapper_native_0x40ae7497 (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper delegate-invoke) <Module>.invoke_intptr__this___intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue[]) <0x00053>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Graphics.Paint.SetShader (Android.Graphics.Shader) <0x0013b>
11-07 08:43:27.186: E/mono-rt(10976):   at GoServicePro.BkgCell.Draw (Android.Graphics.Canvas,System.Drawing.Rectangle,Resco.Controls.AdvancedList.DataSourceItem,bool,Android.Graphics.Paint) <0x001cb>
11-07 08:43:27.186: E/mono-rt(10976):   at Resco.Controls.AdvancedList.AdvancedListCell.OnDraw (Android.Graphics.Canvas) <0x0035b>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x00057>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper dynamic-method) object.257c9c7e-fad9-4199-9a64-706f6b01d970 (intptr,intptr,intptr) <0x00043>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper native-to-managed) object.257c9c7e-fad9-4199-9a64-706f6b01d970 (intptr,intptr,intptr) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at <unknown> <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper managed-to-native) object.wrapper_native_0x40ae69ef (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper delegate-invoke) <Module>.invoke_bool__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.ViewGroup.DrawChild (Android.Graphics.Canvas,Android.Views.View,long) <0x003bb>
11-07 08:43:27.186: E/mono-rt(10976):   at Resco.Controls.AdvancedList.AdvancedList.DrawChild (Android.Graphics.Canvas,Android.Views.View,long) <0x0016b>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.ViewGroup.n_DrawChild_Landroid_graphics_Canvas_Landroid_view_View_J (intptr,intptr,intptr,intptr,long) <0x0009b>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper dynamic-method) object.8090b7a5-436a-4ddb-b0da-b2ab7996ba79 (intptr,intptr,intptr,intptr,long) <0x0006b>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper native-to-managed) object.8090b7a5-436a-4ddb-b0da-b2ab7996ba79 (intptr,intptr,intptr,intptr,long) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at <unknown> <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper managed-to-native) object.wrapper_native_0x40ae61b1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.View.DispatchDraw (Android.Graphics.Canvas) <0x001ef>
11-07 08:43:27.186: E/mono-rt(10976):   at Resco.Controls.Tools.BaseListView.DispatchDraw (Android.Graphics.Canvas) <0x00313>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.View.n_DispatchDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x00057>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper dynamic-method) object.632cf835-0dc0-4bc4-aec5-67f2e32fd6b9 (intptr,intptr,intptr) <0x00043>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper native-to-managed) object.632cf835-0dc0-4bc4-aec5-67f2e32fd6b9 (intptr,intptr,intptr) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at <unknown> <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper managed-to-native) object.wrapper_native_0x40ae61b1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.View.Draw (Android.Graphics.Canvas) <0x001ef>
11-07 08:43:27.186: E/mono-rt(10976):   at Resco.Controls.Tools.BaseListView.Draw (Android.Graphics.Canvas) <0x00143>
11-07 08:43:27.186: E/mono-rt(10976):   at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x00057>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper dynamic-method) object.51b6a81b-94d3-4f1e-a453-dbd919f723b4 (intptr,intptr,intptr) <0x00043>
11-07 08:43:27.186: E/mono-rt(10976):   at (wrapper native-to-managed) object.51b6a81b-94d3-4f1e-a453-dbd919f723b4 (intptr,intptr,intptr) <0xffffffff>
11-07 08:43:27.186: E/mono-rt(10976): =================================================================
11-07 08:43:27.186: E/mono-rt(10976): Got a SIGSEGV while executing native code. This usually indicates
11-07 08:43:27.186: E/mono-rt(10976): a fatal error in the mono runtime or one of the native libraries 
11-07 08:43:27.186: E/mono-rt(10976): used by your application.
11-07 08:43:27.186: E/mono-rt(10976): =================================================================
Comment 15 Sohail Amir 2013-11-08 08:22:40 UTC
Any word on this issue? Thanks.
Comment 16 Sohail Amir 2013-11-08 10:05:42 UTC
I removed the override for BkgCell.Draw method and built the application. This time I got a slightly different stack trace although the error was still the same.

11-08 10:02:58.136: E/mono-rt(22337): Stacktrace:
11-08 10:02:58.136: E/mono-rt(22337):   at <unknown> <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper managed-to-native) object.wrapper_native_0x40ae707b (intptr,intptr,intptr) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Runtime.JNIEnv.CallIntMethod (intptr,intptr) <0x00047>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Graphics.Bitmap.get_Height () <0x0007f>
11-08 10:02:58.136: E/mono-rt(22337):   at Resco.Controls.AdvancedList.ImageCell.DrawContent (Android.Graphics.Canvas,System.Drawing.Rectangle,Resco.Controls.AdvancedList.DataSourceItem,bool,Android.Graphics.Paint) <0x0012b>
11-08 10:02:58.136: E/mono-rt(22337):   at Resco.Controls.AdvancedList.Cell.Draw (Android.Graphics.Canvas,System.Drawing.Rectangle,Resco.Controls.AdvancedList.DataSourceItem,bool,Android.Graphics.Paint) <0x001c7>
11-08 10:02:58.136: E/mono-rt(22337):   at Resco.Controls.AdvancedList.AdvancedListCell.OnDraw (Android.Graphics.Canvas) <0x0035b>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x00057>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper dynamic-method) object.dcb32c1f-a6e0-4e72-87d9-693513614cec (intptr,intptr,intptr) <0x00043>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper native-to-managed) object.dcb32c1f-a6e0-4e72-87d9-693513614cec (intptr,intptr,intptr) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at <unknown> <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper managed-to-native) object.wrapper_native_0x40ae69ef (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper delegate-invoke) <Module>.invoke_bool__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.ViewGroup.DrawChild (Android.Graphics.Canvas,Android.Views.View,long) <0x003bb>
11-08 10:02:58.136: E/mono-rt(22337):   at Resco.Controls.AdvancedList.AdvancedList.DrawChild (Android.Graphics.Canvas,Android.Views.View,long) <0x0016b>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.ViewGroup.n_DrawChild_Landroid_graphics_Canvas_Landroid_view_View_J (intptr,intptr,intptr,intptr,long) <0x0009b>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper dynamic-method) object.42ce009d-2ec5-488c-aabd-40d472bd47a5 (intptr,intptr,intptr,intptr,long) <0x0006b>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper native-to-managed) object.42ce009d-2ec5-488c-aabd-40d472bd47a5 (intptr,intptr,intptr,intptr,long) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at <unknown> <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper managed-to-native) object.wrapper_native_0x40ae61b1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.View.DispatchDraw (Android.Graphics.Canvas) <0x001ef>
11-08 10:02:58.136: E/mono-rt(22337):   at Resco.Controls.Tools.BaseListView.DispatchDraw (Android.Graphics.Canvas) <0x00313>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.View.n_DispatchDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x00057>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper dynamic-method) object.237f0d6c-3bb5-48b3-9d67-f8306ab49085 (intptr,intptr,intptr) <0x00043>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper native-to-managed) object.237f0d6c-3bb5-48b3-9d67-f8306ab49085 (intptr,intptr,intptr) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at <unknown> <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper managed-to-native) object.wrapper_native_0x40ae61b1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.View.Draw (Android.Graphics.Canvas) <0x001ef>
11-08 10:02:58.136: E/mono-rt(22337):   at Resco.Controls.Tools.BaseListView.Draw (Android.Graphics.Canvas) <0x00143>
11-08 10:02:58.136: E/mono-rt(22337):   at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x00057>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper dynamic-method) object.c77e2874-3ef6-45a8-9c41-72c6cf82a5f4 (intptr,intptr,intptr) <0x00043>
11-08 10:02:58.136: E/mono-rt(22337):   at (wrapper native-to-managed) object.c77e2874-3ef6-45a8-9c41-72c6cf82a5f4 (intptr,intptr,intptr) <0xffffffff>
11-08 10:02:58.136: E/mono-rt(22337): =================================================================
11-08 10:02:58.136: E/mono-rt(22337): Got a SIGSEGV while executing native code. This usually indicates
11-08 10:02:58.136: E/mono-rt(22337): a fatal error in the mono runtime or one of the native libraries 
11-08 10:02:58.136: E/mono-rt(22337): used by your application.
11-08 10:02:58.136: E/mono-rt(22337): =================================================================
Comment 17 Jonathan Pryor 2013-11-08 12:59:00 UTC
Both your stack traces have JNIEnv.Call*Method() near the top, e.g.

> 11-08 10:02:58.136: E/mono-rt(22337):   at Android.Runtime.JNIEnv.CallIntMethod

When you get a SIGSEGV from JNIEnv.Call*Method(), this is usually (always?) because you're somehow invoking an instance method on an instance for which Java.Lang.Object.Handle is IntPtr.Zero.

For example, this will cause a SIGSEGV:

    var jli = new Java.Lang.Integer(42);
    jli.Dispose();
    // jli.Handle is now IntPtr.Zero
    var s = jli.ToString (); // BOOM

In the case of Comment #16, the caller is Android.Graphics.Bitmap.get_Height, i.e. the Bitmap has (somehow) been disposed.

Unfortunately, without source it's harder to figure out why the Bitmap would be disposed. That said, I would suggest enabling gref logging:

    adb shell setprop debug.mono.log gref

Then look for all Bitmap creation and disposal, and see if (1) any bitmaps are being disposed before the crash, and (2) where they're being disposed from. Perhaps you can "fix" (2)?
Comment 18 Sohail Amir 2013-11-08 14:41:55 UTC
I will enable gref logging and try what you have suggested. However, the question remain why does this happen only on Mon 4.8.x? The same code works fine if we compile using 4.6.x or earlier. Obviously there is something different in Mono 4.8 that is causing this issue.
Comment 19 Sohail Amir 2013-11-08 15:31:48 UTC
I enabled gref logging and ran the application. However, I am not able to make out from the logging where the relevant objects are being disposed. The log is attached.
Comment 20 Sohail Amir 2013-11-08 15:32:37 UTC
Created attachment 5374 [details]
Gref Log

This is logcat with GREF logging turned on.
Comment 21 Sohail Amir 2013-11-11 13:41:20 UTC
Is it possible that this error is same as mentioned here?

https://bugzilla.xamarin.com/show_bug.cgi?id=13521
Comment 22 Sohail Amir 2013-11-12 10:53:22 UTC
Here is another stack trace. You will notice this has nothing to do with images but I still the SIGSEGV. My guess is this has something to do with the Paint object.

11-12 10:42:49.807: E/mono-rt(20510): Stacktrace:
11-12 10:42:49.807: E/mono-rt(20510):   at <unknown> <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper managed-to-native) object.wrapper_native_0x40b59c27 (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) <0x00053>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Graphics.Paint.set_Color (Android.Graphics.Color) <0x00137>
11-12 10:42:49.807: E/mono-rt(20510):   at Resco.Controls.AdvancedList.TextCell.DrawContent (Android.Graphics.Canvas,System.Drawing.Rectangle,Resco.Controls.AdvancedList.DataSourceItem,bool,Android.Graphics.Paint) <0x000ef>
11-12 10:42:49.807: E/mono-rt(20510):   at Resco.Controls.AdvancedList.Cell.Draw (Android.Graphics.Canvas,System.Drawing.Rectangle,Resco.Controls.AdvancedList.DataSourceItem,bool,Android.Graphics.Paint) <0x001c7>
11-12 10:42:49.807: E/mono-rt(20510):   at Resco.Controls.AdvancedList.AdvancedListCell.OnDraw (Android.Graphics.Canvas) <0x0035b>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x0005b>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper dynamic-method) object.6bae63d2-d505-4dfd-adcb-29d7e23cc0e5 (intptr,intptr,intptr) <0x00043>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper native-to-managed) object.6bae63d2-d505-4dfd-adcb-29d7e23cc0e5 (intptr,intptr,intptr) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at <unknown> <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper managed-to-native) object.wrapper_native_0x40b599ef (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper delegate-invoke) <Module>.invoke_bool__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Views.ViewGroup.DrawChild (Android.Graphics.Canvas,Android.Views.View,long) <0x003bb>
11-12 10:42:49.807: E/mono-rt(20510):   at Resco.Controls.AdvancedList.AdvancedList.DrawChild (Android.Graphics.Canvas,Android.Views.View,long) <0x0016b>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Views.ViewGroup.n_DrawChild_Landroid_graphics_Canvas_Landroid_view_View_J (intptr,intptr,intptr,intptr,long) <0x0009f>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper dynamic-method) object.a61eb826-9f1d-432e-9edd-feb58a611911 (intptr,intptr,intptr,intptr,long) <0x0006b>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper native-to-managed) object.a61eb826-9f1d-432e-9edd-feb58a611911 (intptr,intptr,intptr,intptr,long) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at <unknown> <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper managed-to-native) object.wrapper_native_0x40b591b1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Views.View.DispatchDraw (Android.Graphics.Canvas) <0x001ef>
11-12 10:42:49.807: E/mono-rt(20510):   at Resco.Controls.Tools.BaseListView.DispatchDraw (Android.Graphics.Canvas) <0x00313>
11-12 10:42:49.807: E/mono-rt(20510):   at Android.Views.View.n_DispatchDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x0005b>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper dynamic-method) object.4aaf7ac0-9090-4aaf-9ddd-3526edd19d57 (intptr,intptr,intptr) <0x00043>
11-12 10:42:49.807: E/mono-rt(20510):   at (wrapper native-to-managed) object.4aaf7ac0-9090-4aaf-9ddd-3526edd19d57 (intptr,intptr,intptr) <0xffffffff>
11-12 10:42:49.817: E/mono-rt(20510):   at <unknown> <0xffffffff>
11-12 10:42:49.817: E/mono-rt(20510):   at (wrapper managed-to-native) object.wrapper_native_0x40b591b1 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.817: E/mono-rt(20510):   at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0xffffffff>
11-12 10:42:49.817: E/mono-rt(20510):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00067>
11-12 10:42:49.817: E/mono-rt(20510):   at Android.Views.View.Draw (Android.Graphics.Canvas) <0x001ef>
11-12 10:42:49.817: E/mono-rt(20510):   at Resco.Controls.Tools.BaseListView.Draw (Android.Graphics.Canvas) <0x00143>
11-12 10:42:49.817: E/mono-rt(20510):   at Android.Views.View.n_Draw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) <0x0005b>
11-12 10:42:49.817: E/mono-rt(20510):   at (wrapper dynamic-method) object.7bd1baa0-dee5-4751-9803-8a62b2106c76 (intptr,intptr,intptr) <0x00043>
11-12 10:42:49.817: E/mono-rt(20510):   at (wrapper native-to-managed) object.7bd1baa0-dee5-4751-9803-8a62b2106c76 (intptr,intptr,intptr) <0xffffffff>
11-12 10:42:49.817: E/mono-rt(20510): =================================================================
11-12 10:42:49.817: E/mono-rt(20510): Got a SIGSEGV while executing native code. This usually indicates
11-12 10:42:49.817: E/mono-rt(20510): a fatal error in the mono runtime or one of the native libraries 
11-12 10:42:49.817: E/mono-rt(20510): used by your application.
11-12 10:42:49.817: E/mono-rt(20510): =================================================================
Comment 23 Sohail Amir 2013-11-12 10:53:37 UTC
I also logged the handles of the bitmaps we are creating and searched for the handles in the GREF log. The handles were listed when they were created but there was no instance of them being released in the gref log. See below for an example. Handle 1D20064E is created but not disposed anywhere (I checked the whole gref log).

Images/TabImages/MainForm/workorders_enabled.png:[1D20064E]


11-12 10:42:13.727: I/monodroid-gref(20510): +g+ grefc 224 gwrefc 0 obj-handle 0x42ffcb00/L -> new-handle 0x1d20064e/G from    at Android.Runtime.JNIEnv.NewGlobalRef(IntPtr jobject)
11-12 10:42:13.727: I/monodroid-gref(20510):    at Java.Lang.Object.RegisterInstance(IJavaObject instance, IntPtr value, JniHandleOwnership transfer)
11-12 10:42:13.727: I/monodroid-gref(20510):    at Java.Lang.Object.SetHandle(IntPtr value, JniHandleOwnership transfer)
11-12 10:42:13.727: I/monodroid-gref(20510):    at Java.Lang.Object..ctor(IntPtr handle, JniHandleOwnership transfer)
11-12 10:42:13.727: I/monodroid-gref(20510):    at Android.Graphics.Bitmap..ctor(IntPtr javaReference, JniHandleOwnership transfer)
11-12 10:42:13.727: I/monodroid-gref(20510):    at System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod , System.Object , System.Object[] , System.Exception ByRef )
11-12 10:42:13.727: I/monodroid-gref(20510):    at System.Reflection.MonoCMethod.InternalInvoke(System.Object obj, System.Object[] parameters)
11-12 10:42:13.727: I/monodroid-gref(20510):    at System.Reflection.MonoCMethod.DoInvoke(System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
11-12 10:42:13.727: I/monodroid-gref(20510):    at System.Reflection.MonoCMethod.Invoke(BindingFlags invokeAttr, System.Reflection.Binder binder, System.Objec
11-12 10:42:13.727: I/monodroid-gref(20510): handle 0x1d20064e; key_handle 0x42ffcb00: Java Type: `android/graphics/Bitmap`; MCW type: `Android.Graphics.Bitmap`
Comment 24 Sohail Amir 2013-11-14 17:11:25 UTC
Any progress on this? Today we got a SIGSEGV with a completely new stack trace.

11-14 17:07:14.277: E/mono-rt(28343): Stacktrace:
11-14 17:07:14.277: E/mono-rt(28343):   at <unknown> <0xffffffff>
11-14 17:07:14.277: E/mono-rt(28343):   at (wrapper managed-to-native) System.Threading.NativeEventCalls.SetEvent_internal (intptr) <0xffffffff>
11-14 17:07:14.277: E/mono-rt(28343):   at System.Threading.EventWaitHandle.Set () <0x00053>
11-14 17:07:14.277: E/mono-rt(28343):   at (wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle.Set () <0xffffffff>
11-14 17:07:14.277: E/mono-rt(28343):   at System.Net.WebAsyncResult.SetCompleted (bool,System.Exception) <0x00093>
11-14 17:07:14.277: E/mono-rt(28343):   at System.Net.HttpWebRequest.SetWriteStreamError (System.Net.WebExceptionStatus,System.Exception) <0x00113>
11-14 17:07:14.277: E/mono-rt(28343):   at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest.SetWriteStreamError (System.Net.WebExceptionStatus,System.Exception) <0xffffffff>
11-14 17:07:14.287: E/mono-rt(28343):   at System.Net.WebConnection.InitConnection (object) <0x00207>
11-14 17:07:14.287: E/mono-rt(28343):   at System.Net.WebConnection.<WebConnection>m__1E (object) <0x0001f>
11-14 17:07:14.287: E/mono-rt(28343):   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>
11-14 17:07:14.287: E/mono-rt(28343): =================================================================
11-14 17:07:14.287: E/mono-rt(28343): Got a SIGSEGV while executing native code. This usually indicates
11-14 17:07:14.287: E/mono-rt(28343): a fatal error in the mono runtime or one of the native libraries 
11-14 17:07:14.287: E/mono-rt(28343): used by your application.
11-14 17:07:14.287: E/mono-rt(28343): =================================================================
Comment 25 Jonathan Pryor 2013-11-15 12:26:22 UTC
@Sohail: I looked at the GREF log in Comment #20. The log output looks fine, in that no crash is present.

I do see that Bitmap instance 0x1d800626 was GC'd (though I don't know where in your code it was allocated), and it's the only instance that was GC'd. (The other 3 created Bitmaps were not collected.)

Assuming there isn't multithreading going on, I imagine that the Bitmap instance is created "near":

>  11-08 15:25:46.616: I/monodroid-gref(26567):    at GoServicePro.WindowManager.configureToolbar(Android.Widget.LinearLayout toolbar, System.String configurexml, System.Xml.Linq.XElement buttonsNode, GSP.Phone.Controls.GSPAdvancedList al, WirelessAdvisorBaseline.GSPListItemBase modelItem, Boolean firstInstance, GSP.Phone.Controls.GSPDetailView dv)

as the above comes from the following GREF allocation, so hopefully that can narrow down where the Bitmap is being allocated.
Comment 26 Jonathan Pryor 2013-11-15 12:31:48 UTC
@Sohail: Regarding Comment #21, it is unlikely to be Bug #13521, as that only happens when using other native libraries which invalidate the JNIEnv context for the current thread "underneath" Xamarin.Android.

Comment #22 may be unrelated to Bitmaps, but it appears to be the same "attempting to invoke a Java method on a collected instance" problem.

Comment #24 appears to be an issue in System.Threading, System.Net.WebConnection, or some related part of the framework. An isolated testcase that reproduces the issue would be appreciated.
Comment 27 Sohail Amir 2013-11-25 08:34:26 UTC
Jonathan

We have being going back and forth and Xamarin has suggested that this is a problem with our code. We DO NOT believe this to be the case. If it were, then the application will behave in the same fashion and crash for Mono 4.2.x and 4.2.6 but that is not the case. The application ONLY CRASHES WHEN WE COMPILE IT WITH MONO 4.8.x. 

We have about 400 users using the application at this point and more are being added every day. We have now come to a point when we need a fix URGENTLY 

Either for the crash issue on 4.8.x 
OR 
The original issue that we had reported due to which SSL communications do not work on Android 4.3 when built with Mono version earlier than 4.8. 

Please let me know when can we have this fix.
Comment 28 Sohail Amir 2013-11-25 08:49:01 UTC
To us it looks like the managed objects are being released in places when and where they should not be. Is it possible that there a project setting that is required when building in Mono 4.8.x that perhaps we are not setting correctly?
Comment 30 Sohail Amir 2013-11-25 16:35:39 UTC
This bug has the EXACT same error that we are facing on Mono 4.2.7 app running on Android 4.3. Can we back port the fix to 4.2.7?

https://bugzilla.xamarin.com/show_bug.cgi?id=6501
Comment 31 Sohail Amir 2013-11-26 08:41:11 UTC
I think the problem is that on Android 4.3, the call back validator routine is not called at all.

ServicePointManager.ServerCertificateValidationCallback = Validator;

public static bool Validator(object sender, 
            X509Certificate certificate, X509Chain chain,
            SslPolicyErrors sslPolicyErrors)
        {
            LogMsg("SSL Validator Called");
            return true;
        }

The message "SSL Validator Called" is never logged telling us that a call to that routine is never made.
Comment 32 Sohail Amir 2013-11-27 08:36:10 UTC
Please advice us on the progress of this ticket.
Comment 33 Sohail Amir 2013-12-02 09:37:21 UTC
What is the progress on the issue?
Comment 34 Jonathan Pryor 2013-12-04 17:30:38 UTC
Thoroughly re-reading this report from the beginning, and realizing some critical bits of information were lost.

From the original report:

> When deploying to a Samsung Galaxy Note 3 (Android 4.3) device, the attached
> test project fails with the following error message:

I interpreted this as meaning that the "Error getting response stream" message was coming from device installation, even though this message was not present in either the `adb logcat` output (Attachment #5314 [details]) or the deployment logs (Attachment #5325 [details]).

The project in Comment #12 contains both Debug and Release builds. For giggles, I installed the Release build, ran it, and hit the "Use SSL" button. I promptly saw the "Error getting response stream" message.

I thus believe that the "Error getting response stream" message is NOT an installation message, but instead a runtime message. That changes things SIGNIFICANTLY.

Which brings use to Comment #12's AndroidApplication1/obj/Release/android/AndroidManifest.xml. It does NOT contain the INTERNET permission, which would entirely explain why (1) it failed (INTERNET is required in order to use sockets), and (2) why it worked in Comment #6 (Debug builds automatically add the INTERNET permission, and they were presumably testing a Debug build).
Comment 35 Jonathan Pryor 2013-12-04 17:42:20 UTC
That still leaves the issue from Comment #14. Unfortunately the stack trace for that mentions GoServicePro.BkgCell.Draw(), which is not contained in the sample from Comment #12, which makes investigation difficult.

Comment #16 has a stack trace containing Resco controls, which also isn't in the sample from Comment #12.

Regardless, as mentioned in Comment #17 they look like what happens when you invoke a method on an instance which has a null Handle property.

Comment #18:

> However, the question remain why does this happen only on Mono 4.8.x?

Mono 4.8.x migrated Xamarin.Android from Mono 2.10 to Mono 3.2, which includes a large number of VM and GC changes, fixes, and improvements.

However, there were also some bugs, in particular Bug #13858, in which the GC would prematurely collect instances when it shouldn't. This is fixed in Xamarin.Android 4.10.

I would be willing to blame this on every stack trace that has JNIEnv.Call*Method near the top on Bug #13858.

Have you tried using Xamarin.Android 4.10.1?
Comment 36 Sohail Amir 2013-12-05 08:07:54 UTC
Thanks for the response.

I am not sure what happened that caused INTERNET permission to be missing from Android.XML. Given below is my copy of the manifest for the sample application and as you can see it does have INTERNET permission turned on. The application works correclty when I click "Don't Use SSL" but throws "Error getting response stream (Write: The authentication or decryption has failed" when I click "Use SSL".

Also the callback routine defined in the line is never invoked.

ServicePointManager.ServerCertificateValidationCallback = Validator;

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.Note3Application" android:versionCode="1" android:versionName="1">
	<uses-sdk android:targetSdkVersion="12" />
	<application android:label="Note3Application"></application>
  <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
  <permission android:name="com.GoServicePro.permission.C2D_MESSAGE" android:protectionLevel="signature" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.BATTERY_STATS" />
  <uses-permission android:name="android.permission.CALL_PHONE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
  <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
  <uses-feature android:name="android.hardware.camera" />
  <uses-feature android:name="android.hardware.camera.autofocus" />
  <uses-feature android:name="android.hardware.camera.flash" />
</manifest>
Comment 37 Sohail Amir 2013-12-05 08:09:13 UTC
We have not tried 4.10.1. I will install and try it and let you know what I find.
Comment 38 Sohail Amir 2013-12-05 09:04:33 UTC
I can't get 4.10.1 to even install correctly. I get the attached error.
Comment 39 Sohail Amir 2013-12-05 09:06:01 UTC
Created attachment 5610 [details]
Mono 4.10.1 Error

I can't get 4.10.1 to even install correctly. I get the attached error when I start VS2010. I just have Xamarin.Android installed on the machine.
Comment 40 Sohail Amir 2013-12-05 12:19:03 UTC
Any suggestions on how to get past this 4.10.1 installation issue? I have already tried what is given in

https://bugzilla.xamarin.com/show_bug.cgi?id=12835
Comment 41 dean.ellis 2013-12-05 12:59:24 UTC
Hi 

It looks like the extension hasn't been installed correctly into visual studio. 
I would recommend that you 

1) Uninstall both Xamarin.Andorid and Xamarin.iOS Completely via add remove programs.
2) The re-install the latest 4.10.1 installer.

If you are still getting the error , post the ActivityLog.xml file listed in the error dialog so we can diagnose the issue.
Comment 42 Sohail Amir 2013-12-05 17:32:33 UTC
I uninstalled Mono from Control Panel. Rebooted the machine. Reinstalled. Open VS and got the same error as earlier
"There was an error attempting to initialize the Mono for Android extension."

Here is the stack trace.

System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeMethodInfo' to type 'System.Reflection.ConstructorInfo'.
   at System.ComponentModel.Composition.Caching.AttributedModel.ReflectionCacheServices.GetParameterFromCache(Int32 parameterPosition, Member memberCache, Lazy`1 defaultType)
   at System.ComponentModel.Composition.Caching.AttributedModel.CompositionCacheServices.ReadImportDefinition(ComposablePartDefinition owner, Imp cache)
   at System.ComponentModel.Composition.Caching.AttributedModel.AttributedComposablePartCatalogSite.CreateImportDefinitionFromCache(ComposablePartDefinition owner, Imp cache)
   at Microsoft.VisualStudio.ExtensibilityHosting.CacheCatalog.<>c__DisplayClass9.<GetImportDefinitions>b__8(Imp importCache)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.ComponentModel.Composition.ReflectionModel.ReflectionPartCreationInfo.<GetImports>d__a.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePartDefinition.get_ImportDefinitions()
   at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.get_ImportDefinitions()
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryPreviewImportsStateMachine(PartManager partManager, ComposablePart part, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.PreviewImports(ComposablePart part, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.DetermineRejection(ComposablePartDefinition definition, AtomicComposition parentAtomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.IsRejected(ComposablePartDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer.InternalProvide(ImportDefinition definition, AtomicComposition atomicComposition)
   at Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer.GetExportsCore(ImportDefinition import, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService.PrivateProvideSingle(VsCompositionContainer requestingContainer, List`1 containers, ImportDefinition import, AtomicComposition atomicComposition)
   at Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService.PrivateProvide(VsCompositionContainer requestingContainer, List`1 containers, ImportDefinition import, AtomicComposition atomicComposition)
   at Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService.InternalProvide(VsCompositionContainer container, ImportDefinition import, AtomicComposition atomicComposition)
   at Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer.GetExportsCore(ImportDefinition import, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
   at Mono.VisualStudio.Extension.TastyPackage.Initialize()
   at Mono.Android.VisualStudio.MonoAndroidPackage.Initialize()
Comment 43 Jonathan Pryor 2013-12-05 17:43:54 UTC
> I am not sure what happened that caused INTERNET permission to be
> missing from Android.XML.

I'm not sure either, especially considering that Properties\AndroidManifest.xml does contain the INTERNET permission.

> The application works correclty when I click "Don't Use SSL" but throws
> "Error getting response stream (Write: The authentication or decryption has failed"
>  when I click "Use SSL".

I saw the same behavior.

> Also the callback routine defined in the line is never invoked.

I do not see the same behavior. I see "SSL Validator Called" within the "message" area of the app.

Even with the SSL validator being invoked, it _still_ failed.

Then I viewed the https/SSL url within Chrome, added some extra logging to the app, reinstalled, and NOW it works.

I have no idea. :-/
Comment 44 Jonathan Pryor 2013-12-05 17:56:14 UTC
Ah, I see; If I hit "Don't Use SSL" first, then "Use SSL", it works. If I hit "Use SSL" first, it fails.
Comment 45 Jonathan Pryor 2013-12-05 18:02:16 UTC
So why's it fail?

This is why Exception.Message is terrible, and Exception.ToString() should be used:

> System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Android.Util.AndroidRuntimeException: Exception of type 'Android.Util.AndroidRuntimeException' was thrown.
>   at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in <filename unknown>:0 
>   at Android.Widget.TextView.set_TextFormatted (ICharSequence value) [0x00000] in <filename unknown>:0 
>   at Android.Widget.TextView.set_Text (System.String value) [0x00000] in <filename unknown>:0 
>   at AndroidApplication1.Communication.LogMsg (System.String msg) [0x00021] in /Users/jon/Downloads/bxc-15883/AndroidApplication1/Communication.cs:170 
>   at AndroidApplication1.Communication.Validator (System.Object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors sslPolicyErrors) [0x00006] in /Users/jon/Downloads/bxc-15883/AndroidApplication1/Communication.cs:159 
>   at (wrapper delegate-invoke) <Module>:invoke_bool__this___object_X509Certificate_X509Chain_SslPolicyErrors (object,System.Security.Cryptography.X509Certificates.X509Certificate,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors)
>   at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.SslClientStream.OnRemoteCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.SslStreamBase.RaiseRemoteCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.SslClientStream.RaiseServerCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, AlertDescription description) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
>   --- End of managed exception stack trace ---
> android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
>   at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:5908)
>   at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:837)
>   at android.view.View.requestLayout(View.java:15792)
>   at android.view.View.requestLayout(View.java:15792)
>   at android.view.View.requestLayout(View.java:15792)
>   at android.view.View.requestLayout(View.java:15792)
>   at android.view.View.requestLayout(View.java:15792)
>   at android.widget.TextView.checkForRelayout(TextView.java:6504)
>   at android.widget.TextView.setText(TextView.java:3764)
>   at android.widget.TextView.setText(TextView.java:3622)
>   at android.widget.TextView.setText(TextView.java:3597)
>   at dalvik.system.NativeStart.run(Native Method)
>   --- End of inner exception stack trace ---
>   at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
>   --- End of inner exception stack trace ---
>   at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
>   at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
>   at AndroidApplication1.Communication.FetchURLToByteArray (System.String URL, Int32 timeOut) [0x00076] in /Users/jon/Downloads/bxc-15883/AndroidApplication1/Com

Note that it fails because Validator() is using LogMsg(), which writes to the UI thread.

If I change Validator() to use Console.WriteLine(), the "Use SSL" button works the first time.
Comment 46 Sohail Amir 2013-12-06 08:31:21 UTC
I removed LogMsg() from Validator and recompiled with Mono 4.2.7 and deployed to Android 4.3 device. IT STILL DOES NOT WORK. BTW, in our actual application there is no LogMsg in the validator routine.
Comment 47 Jonathan Pryor 2013-12-06 09:13:25 UTC
@Sohail: What is the _full_ stack trace of the exception, as produced by Exception.ToString()?
Comment 48 Sohail Amir 2013-12-06 10:01:26 UTC
Here is the full stack

WebException: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Java.Lang.Throwable: Exception of type 'Java.Lang.Throwable' was thrown.
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in <filename unknown>:0 
  at Java.Security.Cert.CertificateFactory.GetInstance (System.String type) [0x00000] in <filename unknown>:0 
  at Android.Runtime.AndroidEnvironment.TrustEvaluateSsl2 (Mono.Security.X509.X509CertificateCollection certs, System.Object sender, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors errors) [0x00000] in <filename unknown>:0 
  at (wrapper delegate-invoke) <Module>:invoke_bool__this___X509CertificateCollection_object_X509Certificate2_X509Chain_SslPolicyErrors (Mono.Security.X509.X509CertificateCollection,object,System.Security.Cryptography.X509Certificates.X509Certificate2,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors)
  at System.AndroidPlatform.TrustEvaluateSsl (Mono.Security.X509.X509CertificateCollection collection, System.Object sender, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors errors) [0x00000] in <filename unknown>:0 
  at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.SslClientStream.OnRemoteCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.SslStreamBase.RaiseRemoteCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.SslClientStream.RaiseServerCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  --- End of managed exception stack trace ---
java.security.cert.CertificateException: java.security.NoSuchAlgorithmException: CertificateFactory PKIX implementation not found
	at java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:93)
	at dalvik.system.NativeStart.run(Native Method)
Caused by: java.security.NoSuchAlgorithmException: CertificateFactory PKIX implementation not found
	at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
	at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
	at java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:90)
	... 1 more

  --- End of inner exception stack trace ---
  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at AndroidApplication1.Communication.FetchURLToByteArray (System.String URL, Int32 timeOut) [0x00000] in <filename unknown>:0
Comment 49 Jonathan Pryor 2013-12-06 10:32:59 UTC
Side note: prefixing lines with "> " in bugzilla will prevent line wrapping, making the stack trace significantly easier to read.

The problem is this:

> java.security.cert.CertificateException: java.security.NoSuchAlgorithmException: CertificateFactory PKIX implementation not found
>     at java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:93)
>     at dalvik.system.NativeStart.run(Native Method)
> Caused by: java.security.NoSuchAlgorithmException: CertificateFactory PKIX implementation not found

What Xamarin.Android version are you using? "PKIX" is the TrustManagerFactory.DefaultAlgorithm value, and our SSL code was updated to explicitly use X.509 in:

	https://bugzilla.xamarin.com/show_bug.cgi?id=6501#c10

Xamarin.Android 4.8 introduced the above fix.

Are you sure you're not using an older Xamarin.Android version?
Comment 50 Sohail Amir 2013-12-06 10:50:33 UTC
I must have mentioned 5-6 times in this post that we are using 4.2.7. We tried using 4.8.1 but ran into issues with managed object being released  even though the object was still alive. This caused instability in the application and led to crashes. We tried 4.6 also but it has the same issue with SSL.
Comment 51 Jonathan Pryor 2013-12-06 11:58:16 UTC
> I must have mentioned 5-6 times in this post that we are using 4.2.7

Indeed, and that's so impossibly old to me (15 months) that I just thought you meant you were using Xamarin Studio 4.2.x, not realizing that Xamarin Studio 4.2.2 is the current stable, and 4.2.7 doesn't exist.

_Fifteen months_. There have been at least 111 bug fixes in that time frame, in all areas of the product, including SSL (Bug #6501), which you are currently hitting. Android v4.3 also _removed_ PKIX support, which is why XA 4.6 doesn't work for you either.

Let's see if Dean has any other suggestions on getting 4.10.1 installed...
Comment 52 Sohail Amir 2013-12-06 15:27:00 UTC
Any further word on this? Thanks.
Comment 53 dean.ellis 2013-12-09 04:09:31 UTC
Hi 

If you are still having trouble installing 4.10.1 you can try this method. Some of the older installers might not clear themselves up correctly.

1) Uninstall both VS extensions 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 you 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 verson where 12.0 = VS2013, 11.0 = VS2012 and 10.0 = VS2010.

At this point you should have a completely clean system. You can then try to installed 4.10.1
Comment 54 Sohail Amir 2013-12-09 08:53:35 UTC
Thanks for the response.

Actually I have already tried these steps since they are mentioned in the following bug. (See comment 40).

https://bugzilla.xamarin.com/show_bug.cgi?id=12835

Anyway, I will give it one more shot. Maybe it will work this time.
Comment 55 Sohail Amir 2013-12-09 11:50:36 UTC
No dice. I followed the steps given above for installing 4.10.1 but VS2010 cannot load Xamarin.Android extensions. Here is the stack trace.

> System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeMethodInfo' to type 'System.Reflection.ConstructorInfo'.
>    at System.ComponentModel.Composition.Caching.AttributedModel.ReflectionCacheServices.GetParameterFromCache(Int32 parameterPosition, Member memberCache, Lazy`1 defaultType)
>    at System.ComponentModel.Composition.Caching.AttributedModel.CompositionCacheServices.ReadImportDefinition(ComposablePartDefinition owner, Imp cache)
>    at System.ComponentModel.Composition.Caching.AttributedModel.AttributedComposablePartCatalogSite.CreateImportDefinitionFromCache(ComposablePartDefinition owner, Imp cache)
>    at Microsoft.VisualStudio.ExtensibilityHosting.CacheCatalog.<>c__DisplayClass9.<GetImportDefinitions>b__8(Imp importCache)
>    at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
>    at System.ComponentModel.Composition.ReflectionModel.ReflectionPartCreationInfo.<GetImports>d__a.MoveNext()
>    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
>    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
>    at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePartDefinition.get_ImportDefinitions()
>    at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.get_ImportDefinitions()
>    at System.ComponentModel.Composition.Hosting.ImportEngine.TryPreviewImportsStateMachine(PartManager partManager, ComposablePart part, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ImportEngine.PreviewImports(ComposablePart part, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.CatalogExportProvider.DetermineRejection(ComposablePartDefinition definition, AtomicComposition parentAtomicComposition)
>    at System.ComponentModel.Composition.Hosting.CatalogExportProvider.IsRejected(ComposablePartDefinition definition, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
>    at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
>    at Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer.InternalProvide(ImportDefinition definition, AtomicComposition atomicComposition)
>    at Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer.GetExportsCore(ImportDefinition import, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
>    at Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService.PrivateProvideSingle(VsCompositionContainer requestingContainer, List`1 containers, ImportDefinition import, AtomicComposition atomicComposition)
>    at Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService.PrivateProvide(VsCompositionContainer requestingContainer, List`1 containers, ImportDefinition import, AtomicComposition atomicComposition)
>    at Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService.InternalProvide(VsCompositionContainer container, ImportDefinition import, AtomicComposition atomicComposition)
>    at Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer.GetExportsCore(ImportDefinition import, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
>    at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
>    at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
>    at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
>    at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
>    at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
>    at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
>    at Mono.VisualStudio.Extension.TastyPackage.Initialize()
>    at Mono.Android.VisualStudio.MonoAndroidPackage.Initialize()
Comment 56 dean.ellis 2013-12-09 12:10:34 UTC
Can you post the version information of your Visual Studio versions, as well as any additional extensions you have installed. That cast exception looks like the wrong extension is installed. 

The other option is to try to 4.10.2 which is in the Beta channel at the moment.
Comment 57 Sohail Amir 2013-12-09 12:26:31 UTC
VS2010
Ver: 10.0.40219.1 SP1Rel

Microsoft.NET Framework
ver 4.0.30319 SP1Rel

I have 2 other extensions installed:

1. NShader
2. NuGet Package Manager
Comment 58 Sohail Amir 2013-12-09 13:11:18 UTC
To me it looks like it is trying to load VS2012 extension in VS2010.
Comment 59 Sohail Amir 2013-12-09 14:25:23 UTC
Any word???
Comment 60 Sohail Amir 2013-12-09 20:23:00 UTC
Any updates?
Comment 61 dean.ellis 2013-12-10 04:32:46 UTC
The only difference between my system and yours is I have .net 4.5 installed

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.5.51641 SP1Rel

I installed NShader and it had no effect on the extensions. Can I ask you to install .net 4.5 and see if that corrects the issue?
Comment 62 Sohail Amir 2013-12-10 09:04:36 UTC
Now I have 

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel

Microsoft .NET Framework
Version 4.5.50709 SP1Rel

THE ISSUE IS STILL THERE.
Comment 63 dean.ellis 2013-12-10 09:28:54 UTC
OK. 

Can you zip up the contents of the following directory and attach them to this bug please.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Xamarin

This is assuming you have Visual Studio 2010 installed in the default location. If you do not you will need to find the appropriate directory. 

We need to take a look at the binaries that are being installed on your system by our installer.
Comment 64 Sohail Amir 2013-12-10 12:32:03 UTC
Created attachment 5628 [details]
Contents of Xamarin Folder

Here is the path on my machine. I have a 32-bit installation.

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions
Comment 65 Sohail Amir 2013-12-10 18:29:01 UTC
Any progress??
Comment 66 dean.ellis 2013-12-11 05:54:41 UTC
Thanks for uploading those files. Unfortunately it has not shed any light on this issue, the files are the correct .net 4.0 assemblies and all the dependencies seem to be resolved file here. 

The next step is to use a tool like ILSpy or red gate reflector to see what 'References' are missing from the following assemblies.

in Shell/1.0.0

Mono.VisualStudio.Extension2.dll
Mono.VisualStudio.Shell.dll

in Xamarin.Android/4.10.01073
 
Mono.Android.VisualStudio.dll

There must be a missing or conflicted assembly somewhere that is causing the MEF composition to fail. 

Also what regional settings are being used on the problem machine? We have seen issues before that where due to differences in the decimal seperator setup (for example).
Comment 67 Sohail Amir 2013-12-12 20:39:56 UTC
Update - We were successfully able to install Mono 4.10.1 on a brand new machine and build our application. Preliminary tests look promising. We will keep you posted.

About Mono 4.10.1 though, it gives several ghost errors when building even though the build and deployment succeeds. Also after 4-5 deploys, it refuses to deploy anymore and we have to shut down VS2010 and delete "Release" folder to get it to work again. Here are a few ghost errors that we see.

> Error	78	Access to the path 'resources.apk.bk' is denied.
Comment 68 Sohail Amir 2013-12-13 10:04:28 UTC
More phantom error when building and deploying even though build succeeds

> Error	76	error : The directory is not empty. 		0	0	
> Error	77			0	0
Comment 69 Jonathan Pryor 2013-12-13 10:12:46 UTC
@Sohali: Could you please provide diagnostic build output?

http://docs.xamarin.com/guides/android/deployment,_testing,_and_metrics/diagnostics/#Diagnostic_MSBuild_Output

I don't see why you would be getting "Access to the path 'resources.apk.bk' is denied" errors, as _generally_ it would be trying to create that file within `obj\$(Configuration)`, which _should_ be writable (unless you're out of disk space...?).
Comment 70 Sohail Amir 2013-12-13 10:44:46 UTC
> Error	76	error MSB4018: The "RemoveRegisterAttribute" task failed unexpectedly. 		0	0	
> Error	77	error MSB4018: System.IO.IOException: The process cannot access the file 'C:\Sohail\MyFiles\DotNetProgs\WA-One Android\WAOneAndroid\obj\Release\android\assets\shrunk\Mono.Android.dll' because it is being used by another process. 		0	0
Comment 71 Sohail Amir 2013-12-13 10:46:23 UTC
I have about 200G free on the HDD. Why would it work sometimes and give the error other times?
Comment 72 Sohail Amir 2013-12-13 10:52:14 UTC
> Error	80	The "GenerateJavaStubs" task failed unexpectedly.
> System.IO.FileNotFoundException: Could not find file > > > > > > C:\Users\amirs\AppData\Local\Temp\3shvfoh5.2ri\acw-map.temp'.
> File name: 'C:\Users\amirs\AppData\Local\Temp\3shvfoh5.2ri\acw-map.temp'
>    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
>    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
>    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
>    at Xamarin.Android.Tools.Files.CopyIfChanged(String source, String destination)
>    at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfChanged(String source, String destination)
>    at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
>    at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
>    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
>    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()	WAOneAndroid
Comment 73 Sohail Amir 2013-12-13 10:58:29 UTC
> Error	83	error MSB4018: System.IO.IOException: The process cannot access the file 'C:\Sohail\MyFiles\DotNetProgs\WA-One Android\WAOneAndroid\obj\Release\android\assets\shrunk\Mono.Android.dll' because it is being used by another process. 		0	0
Comment 74 Sohail Amir 2013-12-15 21:55:47 UTC
Another error while building. It works after I clear out "TEMP" folder.

Error	54	The "GenerateJavaStubs" task failed unexpectedly.
System.IO.FileNotFoundException: Could not find file 'C:\Users\amirs\AppData\Local\Temp\23tr3uhv.ksh\acw-map.temp'.
File name: 'C:\Users\amirs\AppData\Local\Temp\23tr3uhv.ksh\acw-map.temp'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at Xamarin.Android.Tools.Files.CopyIfChanged(String source, String destination)
   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfChanged(String source, String destination)
   at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
   at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()	GoServiceProLite
Comment 75 Sohail Amir 2014-01-17 17:22:11 UTC
As you are aware, after upgrading to Mono 4.10.1 the issue that were facing was resolved. We released the application to the users and they have been using it on Android 4.3 or later for more than month now. 

Over the last couple of days, we have seen a couple of instances where the users all of a sudden start getting the error we had reported originally.

"Error getting response stream (Write: The authentication or decryption has
failed)"

In one instance we has to reboot the tablet (Galaxy Note 10.1) and that seemed to fix it. In other instance, it somehow resolved itself. Nothing has changed on the web servers. 

What could be the reason for this error appearing all of a sudden? We will appreciate a quick response.

Regards
Comment 76 Sohail Amir 2014-01-21 09:32:50 UTC
Any word on this this? Thanks
Comment 79 Sohail Amir 2014-01-23 17:19:20 UTC
Can someone PLEASE respond to comment 75?
Comment 80 Jonathan Pryor 2014-01-24 09:30:32 UTC
@Sohali: We believe that the issues you're seeing are due to Bug #10433, which unfortunately has not yet been released, nor am I certain of the exact timeframe for when it will be released. :-(
Comment 81 Sohail Amir 2014-01-24 11:44:26 UTC
Can someone PLEASE respond to comment 75?
Comment 82 Sohail Amir 2014-02-07 12:30:28 UTC
> EXCEPTION:System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Bad record MAC
>   at Mono.Security.Protocol.Tls.RecordProtocol.decryptRecordFragment (ContentType contentType, System.Byte[] fragment) [0x00000] in <filename unknown>:0 
>   at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
>   at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
>   at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
>   at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
>   at Communication.FetchURLToByteArray (System.String URL, Int32 timeOut) [0x00000] in <filename unknown>:0 
> STACK:   at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
>   at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
>   at Communication.FetchURLToByteArray (System.String URL, Int32 timeOut) [0x00000] in <filename unknown>:0
Comment 83 Jonathan Pryor 2014-02-07 15:26:14 UTC
@Sohail: Do you still get "Bad record MAC" messages if you retry?

https://www.google.com/search?q=bad+record+mac
http://stackoverflow.com/a/8160883
Comment 84 Sohail Amir 2014-02-07 18:56:50 UTC
Yes. Sometimes it just heals itself. Sometimes we have to kill and restart the application using Task Manager to correct the issue.
Comment 85 Sohail Amir 2014-02-10 14:30:37 UTC
Any suggestions on what we can do other than kill and restart the application when we encounter this error?
Comment 86 Brendan Zagaeski (Xamarin Team, assistant) 2014-05-14 22:50:51 UTC
A fix for one cause of the "Bad Record MAC" error was recently released (it's in the current beta version Xamarin.Android 4.12.4).

See bug #15293, and the corresponding pull request: https://github.com/mono/mono/pull/929


Hopefully upgrading to this latest version will resolve the problem in your app too!
Comment 89 Cody Beyer (MSFT) 2017-07-12 21:51:34 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.