Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 11234 [details]
Sample Visual Studio extension that reproduces the bug
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 184.108.40.206 (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)
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.
I have checked this issue and able to reproduce the reported behavior with the help of sample and steps given in the bug description.
Debug Logs: https://gist.github.com/saurabh360/a4c76ff951eddc38d190
Android device logs: https://gist.github.com/saurabh360/c037847ce9bb05039bc9
Microsoft Visual Studio Professional 2015
Version 14.0.23011.0 D14REL
Microsoft .NET Framework
Installed Version: Professional
Xamarin 3.11.886.0 (c179066)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android 220.127.116.11 (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 18.104.22.168 (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
Early preview of Xamarin Test Cloud integration
@atin can we retest this in master? I did some changes that should fix this, but cannot confirm right now.
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.