Bug 8501 - System.IO.IOException: DWP Handshake failed.
Summary: System.IO.IOException: DWP Handshake failed.
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 1.8.x
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 23513 ()
Depends on:
Blocks:
 
Reported: 2012-11-19 08:15 UTC by Yvan Rodrigues
Modified: 2015-11-03 14:06 UTC (History)
14 users (show)

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


Attachments
Screenshot (36.02 KB, image/jpeg)
2012-11-19 08:15 UTC, Yvan Rodrigues
Details
Screen Shot of error from case 51999 (56.01 KB, image/png)
2013-11-18 14:31 UTC, Jon Goldberger [MSFT]
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 Yvan Rodrigues 2012-11-19 08:15:06 UTC
There are two other issues with this error, but the symptoms appear to differ.

When a physical Android device is COLD booted and an application is debugged on it, this exception may occur.

Error initializing the debugger: Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> System.IO.IOException: DWP Handshake failed.

Server stack trace: 
   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.<StartConnecting>b__8(IAsyncResult ar)
   --- End of inner exception stack trace ---

The exception is not logged in the Output Window or in the device log.

Subsequent runs do not produce this exception -- a cold booted device is required.
Comment 1 Yvan Rodrigues 2012-11-19 08:15:38 UTC
Created attachment 2966 [details]
Screenshot
Comment 2 Yvan Rodrigues 2012-11-19 08:18:46 UTC
An identical report on the mailing list in May:

http://mono-for-android.1047100.n5.nabble.com/DWP-Handshake-failed-td5678862.html
Comment 3 Krzysztof Karolczak 2013-04-20 05:45:52 UTC
Same here. It happens at every cold boot.
Comment 4 Robert Castles 2013-05-29 07:13:34 UTC
I'll add to the list, as I think I have a particularly difficult device as a stress test.  On my "most difficult device", a nook color with Cyanogenmod 10.1, I am getting this with a normally operating device on every deploy attempt.
Android 4.2.2.

Xamarin 4.6.7, Visual Studio 2012, Windows 7 64 bit.
Comment 5 Robert Castles 2013-06-05 13:28:16 UTC
I have not stressed this test but my initial testing with 4.6.8 seems to be working.
Comment 6 Dominique Louis 2013-06-06 00:52:01 UTC
I will set it to Resolved for now. If you find it is broken, please re-open this bugzilla.
Comment 7 Mikhail 2013-06-17 08:07:58 UTC
I got this issue again.

Visual Sutudio 2012
Xamarin Android plugin version 4.6.8007

I has a complex soludion with binding library project(Google Services) + linked compiled PushSharp library.

The truble of situation is that this issue occures _any_time_ I try to deploy my app to the Android 2.3.6 phone, and almost any time on Android 4.0.4

trace:
Mono.Android.VisualStudio.MonoAndroidPackage Error: 0 : MonoAndroidDebuggerSession
Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> System.IO.IOException: DWP Handshake failed.

Server stack trace: 
   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.<StartConnecting>b__8(IAsyncResult ar)
   --- End of inner exception stack trace ---
Comment 8 Hermann Hubschle 2013-06-27 12:52:43 UTC
Also came across this problem on VS2012, Alpha Android plugin: 4.7.11 

For what it's worth, it resolved itself when I changed both, 'Minimum Android to target' and 'compile using Android version' from 2.2 to 2.3.
Target Android version is 4.03.
Comment 9 Dominique Louis 2013-09-16 12:40:25 UTC
Could you please check that your apps are starting within the 17 second limit, stipulated by Android.
Comment 11 Jon Goldberger [MSFT] 2013-11-18 14:31:09 UTC
Dear Xamarin Support,

Since a few days ago, I am experiencing this kind of error often when trying to debug my application in Visual Studio:

From the debug output I receive these exceptions:

Mono.Android.VisualStudio.MonoAndroidPackage Error: 0 : MonoAndroidDebuggerSession
Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> System.IO.IOException: DWP Handshake failed.

Server stack trace:
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.<StartConnecting>b__8(IAsyncResult ar)
--- End of inner exception stack trace ---
Mono.AndroidTools.AndroidLogger Error: 0 : [E:]: Error in device tracker
System.AggregateException: One or more errors occurred. ---> Mono.AndroidTools.AdbException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.IO.IOException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.Net.Sockets.SocketException: 既存の接続はリモート ホストに強制的に切断されました。
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
at Mono.AndroidTools.Adb.ReadFullAsyncResult.EndRead(IAsyncResult ar)
at Mono.AndroidTools.Adb.AdbClient.ReadStringWithLength_OnReadLength(IAsyncResult ar)
--- End of inner exception stack trace ---
at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
at Mono.AndroidTools.Adb.AdbClient.EndReadStringWithLength(IAsyncResult asyncResult)
at Mono.AndroidTools.TrackDeviceTask.GotString(IAsyncResult r)
--- End of inner exception stack trace ---
---> (Inner Exception #0) Mono.AndroidTools.AdbException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.IO.IOException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.Net.Sockets.SocketException: 既存の接続はリモート ホストに強制的に切断されました。
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
at Mono.AndroidTools.Adb.ReadFullAsyncResult.EndRead(IAsyncResult ar)
at Mono.AndroidTools.Adb.AdbClient.ReadStringWithLength_OnReadLength(IAsyncResult ar)
--- End of inner exception stack trace ---
at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
at Mono.AndroidTools.Adb.AdbClient.EndReadStringWithLength(IAsyncResult asyncResult)
at Mono.AndroidTools.TrackDeviceTask.GotString(IAsyncResult r)<---

Mono.Android.VisualStudio.MonoAndroidPackage Error: 0 : Background task error
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.ArgumentException: Controls created on one thread cannot be parented to a control on a different thread.
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.WindowsFormsUtils.ReadOnlyControlCollection.AddInternal(Control value)
at System.Windows.Forms.ToolStripControlHost.SyncControlParent()
at System.Windows.Forms.ToolStripControlHost.OnParentChanged(ToolStrip oldParent, ToolStrip newParent)
at System.Windows.Forms.ToolStripItem.set_ParentInternal(ToolStrip value)
at System.Windows.Forms.ToolStripSplitStackLayout.LayoutHorizontal()
at System.Windows.Forms.ToolStripSplitStackLayout.LayoutCore(IArrangedElement container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ToolStrip.OnLayout(LayoutEventArgs e)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
at System.Windows.Forms.ToolStripItem.InvalidateItemLayout(String affectedProperty, Boolean invalidatePainting)
at System.Windows.Forms.ToolStripItem.set_ImageIndex(Int32 value)
at System.Windows.Forms.ToolStripItem.set_Image(Image value)
at Mono.Android.VisualStudio.LogCatControl.StopLogging()
at Mono.Android.VisualStudio.LogCatControl.<StartLogging>b__2(Task task)
at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: Controls created on one thread cannot be parented to a control on a different thread.
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.WindowsFormsUtils.ReadOnlyControlCollection.AddInternal(Control value)
at System.Windows.Forms.ToolStripControlHost.SyncControlParent()
at System.Windows.Forms.ToolStripControlHost.OnParentChanged(ToolStrip oldParent, ToolStrip newParent)
at System.Windows.Forms.ToolStripItem.set_ParentInternal(ToolStrip value)
at System.Windows.Forms.ToolStripSplitStackLayout.LayoutHorizontal()
at System.Windows.Forms.ToolStripSplitStackLayout.LayoutCore(IArrangedElement container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ToolStrip.OnLayout(LayoutEventArgs e)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
at System.Windows.Forms.ToolStripItem.InvalidateItemLayout(String affectedProperty, Boolean invalidatePainting)
at System.Windows.Forms.ToolStripItem.set_ImageIndex(Int32 value)
at System.Windows.Forms.ToolStripItem.set_Image(Image value)
at Mono.Android.VisualStudio.LogCatControl.StopLogging()
at Mono.Android.VisualStudio.LogCatControl.<StartLogging>b__2(Task task)
at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
at System.Threading.Tasks.Task.Execute()<---

Mono.Android.VisualStudio.MonoAndroidPackage Error: 0 : Background task error
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> Mono.AndroidTools.AdbException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.IO.IOException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.Net.Sockets.SocketException: 既存の接続はリモート ホストに強制的に切断されました。
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
at Mono.AndroidTools.Adb.AdbClient.ReadText_OnReadText(IAsyncResult ar)
--- End of inner exception stack trace ---
at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
at Mono.AndroidTools.Adb.AdbClient.EndReadText(IAsyncResult ar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of inner exception stack trace ---
---> (Inner Exception #0) Mono.AndroidTools.AdbException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.IO.IOException: Unable to read data from the transport connection: 既存の接続はリモート ホストに強制的に切断されました。. ---> System.Net.Sockets.SocketException: 既存の接続はリモート ホストに強制的に切断されました。
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
at Mono.AndroidTools.Adb.AdbClient.ReadText_OnReadText(IAsyncResult ar)
--- End of inner exception stack trace ---
at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
at Mono.AndroidTools.Adb.AdbClient.EndReadText(IAsyncResult ar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)<---

Mono.Android.VisualStudio.MonoAndroidPackage Error: 0 : MonoAndroidDebuggerSession
Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> System.IO.IOException: DWP Handshake failed.

Server stack trace:
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.<StartConnecting>b__8(IAsyncResult ar)
--- End of inner exception stack trace ---
Comment 12 Jon Goldberger [MSFT] 2013-11-18 14:31:48 UTC
Created attachment 5463 [details]
Screen Shot of error from case 51999
Comment 13 Jon Goldberger [MSFT] 2013-11-18 20:37:39 UTC
Version and additional info from case 51999:
Additional info:
Last time this bug happened, I noticed that there were a lot of instances of a program called “conhost.exe” in the taskmanager.
I removed them all and the bug disappeared.

Version information:
Below is the full version information from VS2012:
=================================================
Microsoft Visual Studio Premium 2012
Version 11.0.60610.01 Update 3
Microsoft .NET Framework
Version 4.5.50709

Installed Version: Premium

LightSwitch for Visual Studio 2012 04941-004-0043007-02599
Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools 04941-004-0043007-02599
Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012 04941-004-0043007-02599
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012 04941-004-0043007-02599
Microsoft Visual Basic 2012

Visual C# 2012 04941-004-0043007-02599
Microsoft Visual C# 2012

Visual C++ 2012 04941-004-0043007-02599
Microsoft Visual C++ 2012

Visual F# 2012 04941-004-0043007-02599
Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker 04941-004-0043007-02599
Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools 04941-004-0043007-02599
Microsoft Visual Studio 2012 SharePoint Developer Tools

NuGet Package Manager 2.2.40116.9051
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer 1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools 11.1.20627.00
Microsoft SQL Server Data Tools

Web Developer Tools 1.2.40308.0
Microsoft Web Developer Tools contains the following components:
Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
Web Form Templates: Includes the default templates for Web Form Applications.
Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.

Xamarin.Android 4.8.01013 (b76e8ec4)
Visual Studio plugin to enable development for Xamarin.Android.
=================================================
Comment 14 PJ 2013-11-19 16:38:19 UTC
This bug was targeted for a past milestone, moving to the next active non-hotfix milestone.
Comment 17 Peter Collins 2015-01-23 13:33:38 UTC
*** Bug 23513 has been marked as a duplicate of this bug. ***