According to MSDN docs , Debugger.Break() should pause the app execution and allow one to connect the debugger if the debugger is not connected. However in Xamarin Studio (and Visual Studio) the app just crashes.
The workaround is to check if the debugger is attached before calling this method:
"If no debugger is attached, users are asked if they want to attach a debugger. "
## Steps to reproduce:
1. Create a new iOS Single View project in Xamarin Studio.
2. Override the ViewDidAppear method in the ViewController.cs file and add this line to it:
2. Select Debug configuration
3. Launch to device/simulator
4. When the app breaks at the line added in step 2, press Stop to close the app and disconnect the debugger.
5 Launch the app from the home screen of the device simulator.
Expected result: You will be asked if you want to attach the debugger.
Actual result: App crashes.
I realize that it would be best to wrap the Debugger.Break call in the above check to see if the debugger is attached, or at least a compiler directive so the method is not called in release builds, but I am filing this in case I am incorrect and this method should either be ignored if the debugger is not attached or should break and ask if the developer wants to attach the debugger as indicated in the MSDN doc  linked above.
## Version Info:
=== Xamarin Studio ===
Version 5.10 (build 704)
Installation UUID: 964c531b-d928-456b-a9ae-e1f82266b360
Mono 4.2.0 (explicit/2701b19)
GTK+ 2.24.23 (Raleigh theme)
Package version: 402000207
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 6.4 (7720)
=== Xamarin.Mac ===
Version: 18.104.22.168 (Business Edition)
=== Xamarin.Android ===
Version: 22.214.171.1243 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
SDK Tools Version: 24.3.4
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23
Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
=== Xamarin Android Player ===
Location: /Applications/Xamarin Android Player.app
=== Xamarin.iOS ===
Version: 126.96.36.199 (Business Edition)
Build date: 2015-08-31 15:32:33-0400
=== Build Information ===
Release ID: 510000704
Git revision: c16e63aeeaa63ea912638f958ae1547905aed4e5
Build date: 2015-08-31 15:47:00-04
Xamarin addins: a7a74af8bcc6bca9a02f34afb66025c0a3fa18cb
Build lane: monodevelop-lion-master
=== Operating System ===
Mac OS X 10.10.5
Darwin Jons-iMac.local 14.5.0 Darwin Kernel Version 14.5.0
Wed Jul 29 02:26:53 PDT 2015
## Counter-example of Windows console C# app in Visual Studio (it also contradicts the MSDN docs)
The following program crashes if you choose "Run -> Start Without Debugging" in Visual Studio 2013 (or compile it and then double-click the `.exe` in Explorer):
static void Main(string args)
## It appears Xamarin's behavior is consistent with the actual in-practice behavior of desktop .NET
This enhancement isn't quite "resolved upstream" since the Mono soft debugger would need its own special handling for this scenario. But it might be "RESOLVED INVALID" since the current behavior of the Mono soft debugger is consistent with the behavior of a Windows console C# app in Visual Studio.
For the moment, I will simply change this report to be an enhancement. If the original reporting customer can demonstrate a use case for `Debugger.Break()` that succeeds in a Windows app in Visual Studio but fails in Xamarin apps, we can re-evaluate that assignment.
Small correction to my previous comment: rather than "RESOLVED INVALID", "RESOLVED NOT_ON_ROADMAP" would probably be the better, more descriptive status for this enhancement if the developers decide to resolve it without changing Xamarin's behavior.
In case of Android/iOS... how/where should "You will be asked if you want to attach the debugger." appear? In Android/iOS app as popup? Also... we currently don't have support for attaching debugger to running process.
Since this is mostly runtime thing(crashing). I'm moving bug to runtime.
Fixed in mono master 15bee580fd88814e5baa77c181e8bb06b8efe7fa/4.2 11ce499c406bc09c4c3b4a2def21618cbdb8696d.
The fix will be in the next major Xamarin.ios release.