Bug 26179 - [XVS 3.9, Unified Devices] Visual Studio hangs when attempting to debug on non-existent "Device" device
Summary: [XVS 3.9, Unified Devices] Visual Studio hangs when attempting to debug on no...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.9
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Brendan Zagaeski (Xamarin Team, assistant)
URL:
Depends on:
Blocks:
 
Reported: 2015-01-19 19:40 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-01-07 17:50 UTC (History)
4 users (show)

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


Attachments
Windows Event Viewer managed exeption log entry (12.35 KB, text/plain)
2015-01-19 19:40 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2015-01-19 19:40:35 UTC
Created attachment 9405 [details]
Windows Event Viewer managed exeption log entry

[XVS 3.9, Unified Devices] Visual Studio hangs when attempting to debug on non-existent "Device" device


Regression status: new feature bug for Unified Devices feature in XVS 3.9


This bug has similar symptoms to bug 25212, but it's slightly different because:

1. This problem could in theory be avoided by removing the "fake" "Device" entry from the Unified Devices menu or by blocking VS from attempting to debug when it deploys to the "Device" entry.

2. It still occurs in version 3.9.268.



Note: according to my brief tests, this problem appears to be fixed in 3.9.274.0 (74260cb).



## "Workaround"

Do not attempt to start debugging when the "Device" entry is selected in the Run / Unified Devices drop-down menu. Either select a real device or simulator, or only _build_ the solution (for example, via Visual Studio's "Build" menu) rather than pushing the Run button.

Since this workaround is fairly easy and doesn't block normal development, I'll leave the bug severity as "Normal".


## Steps to reproduce 

1. Create a new iOS app. (I think probably any template will work.)

2. Set the iOS app as the startup project.

3. Pair to the Mac build host.

4. Make sure you don't have any devices connected.

5. Select the entry named "Device" from the drop-down Run / Unified Devices menu.

6. Click the Run button.



## Results

VS hangs. If you wait long enough VS either crashes or shows the same exception as 3.9.246.


The Windows Event Viewer logs contain a corresponding managed exception. Here's the top of that log entry:

> Application: devenv.exe
> Framework Version: v4.0.30319
> Description: The process was terminated due to an unhandled exception.
> Exception Info: System.ComponentModel.Win32Exception
> Stack:
>    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
>    at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
>    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
>    at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
>    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)


(Complete log entry attached.)



## Results on 3.9.246 (or sometimes also 3.9.268)

VS hangs. If you wait long enough, the following error appears in the Error List and in the Output window:

> Launching Application for debugging...
> There was an unhandled exception trying to deploy and run your application.
> System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Debug port cannot be zero when connecting
> Parameter name: debugPort
>    at Mono.Debugging.Soft.SoftDebuggerConnectArgs..ctor(String appName, IPAddress address, Int32 debugPort, Int32 outputPort)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.CreateDebuggerStartInfo(VSBuildServerClient server, MonoTouchDevice device, MonoTouchFlavoredProject project, IVsDebugger2 debugger, Int32 debugPort, Int32 consolePort)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.GetDebugSession(VSBuildServerClient server, MonoTouchFlavoredProject project, MonoTouchDevice device, String outputDirectory, IVsDebugger2 debugger, IVsOutputWindowPane output, Int32& appConsolePort)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.DebugApplication(VSBuildServerClient server, MonoTouchDevice device, IVsOutputWindowPane output, MonoTouchProgressNotifier notifier, LogReader consoleLogReader)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.<>c__DisplayClassa.<DebugLaunchHack>b__6(VSBuildServerClient server)
>    at Xamarin.VisualStudio.IOS.Utilities.BuildServer.<>c__DisplayClass88`1.<RunOnlyIfConnected>b__86()
>    at System.Threading.Tasks.Task`1.InnerInvoke()
>    at System.Threading.Tasks.Task.Execute()
>    --- End of inner exception stack trace ---
>    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
>    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
>    at System.Threading.Tasks.Task`1.get_Result()
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.DebugLaunchHack(__VSDBGLAUNCHFLAGS grfLaunch)
> ---> (Inner Exception #0) System.ArgumentException: Debug port cannot be zero when connecting
> Parameter name: debugPort
>    at Mono.Debugging.Soft.SoftDebuggerConnectArgs..ctor(String appName, IPAddress address, Int32 debugPort, Int32 outputPort)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.CreateDebuggerStartInfo(VSBuildServerClient server, MonoTouchDevice device, MonoTouchFlavoredProject project, IVsDebugger2 debugger, Int32 debugPort, Int32 consolePort)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.GetDebugSession(VSBuildServerClient server, MonoTouchFlavoredProject project, MonoTouchDevice device, String outputDirectory, IVsDebugger2 debugger, IVsOutputWindowPane output, Int32& appConsolePort)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.DebugApplication(VSBuildServerClient server, MonoTouchDevice device, IVsOutputWindowPane output, MonoTouchProgressNotifier notifier, LogReader consoleLogReader)
>    at Xamarin.VisualStudio.IOS.MonoTouchFlavoredProject.<>c__DisplayClassa.<DebugLaunchHack>b__6(VSBuildServerClient server)
>    at Xamarin.VisualStudio.IOS.Utilities.BuildServer.<>c__DisplayClass88`1.<RunOnlyIfConnected>b__86()
>    at System.Threading.Tasks.Task`1.InnerInvoke()
>    at System.Threading.Tasks.Task.Execute()<---
> Stopping debugger...
> Debugging session ended.


## Additional version information

Window 8.1, 64-bit in VMWare Fusion 6.0.5 (2209127)

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Xamarin   3.9.268.0 (f66505f)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.1.0 (dd1b996f9fab5be032c5bfc54df1bc445953e90f)


## Mac
Xamarin.iOS 8.6.0.51, Hash: dfb682f
OS X 10.9.5
Comment 1 mag@xamarin.com 2016-01-07 17:50:03 UTC
This issue is already fixed on current master branch. Please try with latest master bits.