Bug 12684 - Could not connect to the debugger
Summary: Could not connect to the debugger
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
Depends on:
Reported: 2013-06-14 01:47 UTC by Pavlos Touboulidis
Modified: 2016-09-10 07:59 UTC (History)
18 users (show)

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

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 for Bug 12684 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Pavlos Touboulidis 2013-06-14 01:47:01 UTC
Cross-posted from: https://bugs.archlinux.org/task/35637

For some time now, debugging with MonoDevelop does not work. Trying to debug even the simplest console application gives the following error:

"Could not connect to the debugger".
"debugger-agent: Unable to connect to" (port is random)

Additional info:
Sorry, I can't recall at what version this started happening but we're at 4.0.8-1 now.

I don't think it's related to the version of mono that's installed, since I get the same error consistently with mono 2.9.10, 3.0.7 or 3.0.12 (git).

And here's the output from the log file:

ERROR [2013-06-04 12:36:18Z]: Error in debugger
Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> System.Net.Sockets.SocketException: interrupted
at System.Net.Sockets.Socket.Accept () [0x0006d] in /build/mono/src/mono-3.0.7/mcs/class/System/System.Net.Sockets/Socket.cs:553
at Mono.Debugger.Soft.VirtualMachineManager.LaunchInternal (ITargetProcess p, System.Diagnostics.ProcessStartInfo info, System.Net.Sockets.Socket socket) [0x00004] in /build/monodevelop/src/monodevelop-4.0.8/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs:49
--- End of inner exception stack trace ---

Steps to reproduce:
* Start MonoDevelop
* Open/create any C# application
* Start debugging

P.S. Someone else is having the same problem over at stackoverflow: http://stackoverflow.com/questions/16866207/unable-to-hit-breakpoints-in-monodevelop
Comment 1 Pavlos Touboulidis 2013-06-14 15:26:44 UTC
As suggested by someone on the aforementioned stackoverflow question, I unticked the "Run on external console" checkbox in the project run settings and now it works.
Comment 2 Rodrigo Kumpera 2013-06-17 15:01:22 UTC
Since there's a simple workaround, let's close it.
Comment 3 Zoltan Varga 2013-06-17 15:52:33 UTC
-> reopen. this is still a bug.
Comment 4 bfhben 2013-10-07 15:58:48 UTC
This bug appears to be specific to gnome-terminal though it may occur with mate-terminal too. Gnome removed the --disable-factory argument for Gnome terminal as far as I can tell due to a regression which make it have no effect (explained at https://mail.gnome.org/archives/commits-list/2013-September/msg05584.html ). Without looking too much further the simplest fix appears to be to just change the default terminal on Gnome to something such as xterm, which, though maybe not ideal, does still work.
Comment 5 bfhben 2013-10-07 15:59:35 UTC
Submitted pull request for basic fix at https://github.com/mono/monodevelop/pull/414
Comment 6 Roman M. Yagodin 2013-10-09 01:56:54 UTC
The below hack for non-GNOME desktops like LXDE or XFCE was worked later for gnome-terminal 3.4 and 3.6, but no more on 3.8. The idea is to make MonoDevelop think that it invokes xterm:

> sudo apt-get remove xterm
> sudo ln -s /usr/bin/gnome-terminal.wrapper /usr/bin/xterm

But now, we stick to xterm even in GNOME. Since MonoDevelop checks GNOME_DESKTOP_SESSION_ID environment variable in order to use gnome-terminal, unsetting it makes MonoDevelop fallback to xterm:   

> monodevelop

I really want to use native terminal emulators for the desktops I've use in development and presentations. So consider #8484 too - users should have ability to setup their own terminal emulator for execute and debug.
Comment 7 susanta sahu 2013-12-25 09:21:17 UTC
Breakpoints: It is important to point out that the iOS gives applications only a handful of seconds (10) to startup and complete the FinishedLaunching method in the Application delegate. If the application does not complete this method in 10 seconds, the OS will kill the process.
Comment 8 susanta sahu 2013-12-25 09:46:38 UTC
Run->Debug from the menu. Once the upload is complete, you will see this message: "Waiting for Debugger to connect" 

then you should manually launch the application on the device, it will connect to your Xamarin Studio and initiate debugging.

Breakpoints: It is important to point out that the iOS gives applications only a handful of seconds (10) to startup and complete the FinishedLaunching method in the Application delegate. If the application does not complete this method in 10 seconds, the OS will kill the process.

Guys please check that your FinishedLaunching execution completes with in 6-7 seconds, 

then it will start
Comment 9 Ben DeCamp 2014-06-26 21:56:55 UTC
It appears that the Gnome Devs did provide an alternative for --disable-factory:  https://wiki.gnome.org/Apps/Terminal/Debugging
However, gnome-terminal-server now resides at /usr/lib/gnome-terminal/gnome-terminal-server

Did a quick test to confirm that if no terminal clients connect to the newly created terminal server within 10 seconds, the terminal server will self-terminate. It also appears to self-terminate after the last client has been disconnected (closed.)

This might be more tedious than the previous --disable-factory argument, but it'd be nice to still support the native gnome-terminal in some way.
Comment 12 Aaron 2015-03-18 17:25:24 UTC
The workaround on comment 2 worked for me, but it is useless because I need to see console messages as I'm debugging.
I've installed xterm, unset GNOME_SESSION_DESKTOP_ID and still I can't do that.
How can I debug a console application using xterm instead of gnome-terminal?
Comment 13 Aaron 2015-03-18 17:27:37 UTC
Ah, I forgot to mention that I'm using MonoDevelop 5.7 and this issue still isn't solved.
Comment 14 Carlos 2015-04-08 13:44:14 UTC
Aaron, I have the same problem. Are you using 64 bit ?

I'm on 64 bit Linux OpenSUSE.
Comment 15 Daniel Isenmann 2015-07-21 15:11:36 UTC
What is the status of this bug? Is this still valid? Will it be fixed soon?
Comment 16 Roman M. Yagodin 2015-07-22 01:46:57 UTC
Yes, it still an issue in MonoDevelop 5.9.4
Comment 17 nanatsuno 2015-07-22 17:49:04 UTC
The problem persists and it's tied to Gnome desktop environment apparently. Confirmed on Fedora 22 (Gnome) + MonoDevelop 5.9.4
Comment 18 debianlinuxero1 2016-03-01 23:10:29 UTC
I have v.5.10.

I don't see that option.

The problem continues.


And I don't see any option to choose the terminal program either.
Comment 19 daniel.fraknoy 2016-03-03 20:38:54 UTC
Just want to confirm that on OpenSuse Thumbleweed, Gnome 3.18, Xamarin 5.10
The problem still persists.
Comment 20 debianmik@gmail.com 2016-03-17 20:29:26 UTC
Fedora 23 x64, Gnome 3.18, MonoDevelop 5.9.7. The problem still persists.
Comment 21 Ardi renaldi 2016-05-14 10:03:17 UTC
> sudo monodevelop
Works for me :)
Comment 22 o.jot 2016-09-10 07:59:48 UTC
Using arch linux 64bit with gnome.
Had same problem, but for some reason everything works when I run from terminal
> monodevelop