Home » Android » debugging – Xamarin Android (Visual Studio 2015) Could not connect to the debugger

debugging – Xamarin Android (Visual Studio 2015) Could not connect to the debugger

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have a problem with the android debugger (Visual Studio 2015) as it always stops immediately after starting debug (it works just fine without debugging), I had my machine reset and reinstalled Visual Studio 2015 but it does not help.

Here is the log from logcat: monodroid-debug Error accepting stdout and stderr (127.0.0.1:8896) Address already in use

Here is the log from Xamarin log:

Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> Mono.Debugger.Soft.VMDisconnectedException: Exception of type 'Mono.Debugger.Soft.VMDisconnectedException' was thrown.

Server stack trace: 
at Mono.Debugger.Soft.Connection.SendReceive(CommandSet command_set, Int32 command, PacketWriter packet)
at Mono.Debugger.Soft.Connection.VM_GetVersion()
at Mono.Debugger.Soft.Connection.Connect()
at Mono.Debugger.Soft.VirtualMachine.connect()
at Mono.Debugger.Soft.VirtualMachineManager.Connect(Connection transport, StreamReader standardOutput, StreamReader standardError)
at Mono.Debugger.Soft.VirtualMachineManager.ConnectInternal(Socket dbg_sock, Socket con_sock, IPEndPoint dbg_ep, IPEndPoint con_ep)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]: 
at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
at Mono.Debugger.Soft.VirtualMachineManager.ConnectCallback.EndInvoke(IAsyncResult result)
at Mono.Debugger.Soft.VirtualMachineManager.EndConnect(IAsyncResult asyncResult)
at Mono.Debugging.Soft.SoftDebuggerSession.<>c__DisplayClass9.b__8(IAsyncResult ar)
--- End of inner exception stack trace ---

Any help is much appreciated!

How to&Answers:

I had same issue and I was able to connect debugger by following this:

http://dotnetbyexample.blogspot.cz/2016/02/fix-for-could-not-connect-to-debugger.html

In short:

  • Disable “Use fast deployment (debug mode only)” in Android project -> Properties -> Android options -> Packaging

  • Enable “Migrate to a physical computer with a different processor version” in Hyper-V manager go to VM -> Settings -> Processor -> Compatibility

Answer:

For me, this turns out to be an issue of DELL laptop running on Windows 10, after I rolled back to Windows 8.1, it works fine now

Answer:

Error accepting stdout and stderr (127.0.0.1:8896) Address already in use

This has been reported to Xamarin as Bug 34476.

Answer:

Though the question is for VS 2015. Recently with visual studio 2017 version 15.2 has this issue.
Uninstalling the visual studio and downgrading to previous working VS helped in my case. Hope soon they will fix the bug.
https://forums.xamarin.com/discussion/95555/how-to-downgrade-visual-studio-2017-version-15-2-to-15-0

Answer:

I had the same issue on VS 2019.

What fixed it for me was deleting my emulator and re-adding it again.