Bug 30193 - Xamarin.Android throws InvalidCastException on IDebugStackFrame2.GetDocumentContext (conflicts with OzCode)
Summary: Xamarin.Android throws InvalidCastException on IDebugStackFrame2.GetDocumentC...
Status: RESOLVED ANSWERED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 0.x Insider Preview
Hardware: PC Windows
: Normal normal
Target Milestone: 4.3.0 (C9)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-18 11:54 UTC by Omer Raviv
Modified: 2016-12-23 19:11 UTC (History)
9 users (show)

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


Attachments
Sample Visual Studio extension that reproduces the bug (54.29 KB, application/x-zip-compressed)
2015-05-18 11:54 UTC, Omer Raviv
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 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 ANSWERED

Description Omer Raviv 2015-05-18 11:54:58 UTC
Created attachment 11234 [details]
Sample Visual Studio extension that reproduces the bug

Hi,

I'm an author of a VS Extension (http://www.oz-code.com). I'm testing my extension against Visual Studio 2015 RC with Xamarin.Android   5.1.1.3 (690e31db450bd2ae1517eb04840f76e23f3f6925). When running a blank Android app and hitting a breakpoint, whenever my extension calls the VSSDK's IDebugStackFrame2.GetDocumentContext method, it throws the following exception:

System.InvalidCastException: Unable to cast object of type 'Xamarin.VisualStudio.Debugger.AD7DocumentContext' to type 'Microsoft.VisualStudio.Debugger.Interop.IDebugDocumentContext2'.
   at System.StubHelpers.InterfaceMarshaler.ConvertToManaged(IntPtr pUnk, IntPtr itfMT, IntPtr classMT, Int32 flags)
   at Microsoft.VisualStudio.Debugger.Interop.IDebugStackFrame2.GetDocumentContext(IDebugDocumentContext2& ppCxt)


To reproduce:
1.	Open the attached sample Visual Studio Extension (XamarinGetDocumentContextFailure.csproj).
2.	Put a breakpoint on the MenuItemCallback method.
3.	Hit F5. A new instance of Visual Studio will pop up.
4.	In the new instance, open the attached BlankAndroidApp.csproj  (or any other Xamarin.Android project for that matter) 
5.	Put a breakpoint on the OnCreate method and hit F5
6.	When the breakpoint hits, then click Tools->ReproduceBug
7.	You will hit a breakpoint in your first Visual Studio. Step the call to GetDocumentContext and you will see it unexpectedly throws the exception.
Comment 1 Atin 2015-08-21 13:01:08 UTC
I have checked this issue and able to reproduce the reported behavior with the help of sample and steps given in the bug description.

Screencast: http://www.screencast.com/t/2I2EoGIgPa
Screencast: http://www.screencast.com/t/KITxzzz4YgDj
Debug Logs: https://gist.github.com/saurabh360/a4c76ff951eddc38d190
Error: https://gist.github.com/saurabh360/159f4b9a08c90f8a5dff
Android device logs: https://gist.github.com/saurabh360/c037847ce9bb05039bc9

Environment Info: 

Microsoft Visual Studio Professional 2015
Version 14.0.23011.0 D14REL
Microsoft .NET Framework
Version 4.6.00076

Installed Version: Professional


Xamarin   3.11.886.0 (c179066)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.6.3 (6050d6bdf1e1f7e60a4bdf74a7d2a08b479a076d)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.5.0 (4eb4d5bdacb34b4f2b823d9410a5d8d4effa383a)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 2 Joaquin Jares 2015-09-15 15:46:16 UTC
@atin can we retest this in master? I did some changes that should fix this, but cannot confirm right now.
Comment 3 Juan Marcelo Tondato 2016-12-23 19:11:06 UTC
Hi,
As we've added several improvements to our debug mechanism since the bug was reported, I'm resolving it. That said, if you're still facing this issue with current bits, please feel free to reopen the bug.
Thanks