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

Khang Tran picture Khang Tran · Sep 15, 2015 · Viewed 11.8k times · Source

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!

Answer

akl22 picture akl22 · Apr 10, 2016

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