Bug 29741 - Build failed on device - disconnected from the server unexpectedly, builds for simulator
Summary: Build failed on device - disconnected from the server unexpectedly, builds fo...
Status: RESOLVED DUPLICATE of bug 31239
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.11 (C5)
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: mag@xamarin.com
Depends on:
Reported: 2015-05-05 06:37 UTC by Danil Kurkin
Modified: 2016-12-22 18:07 UTC (History)
11 users (show)

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

Done executing task "MTouch" -- FAILED (2.75 MB, application/x-zip-compressed)
2015-05-19 04:50 UTC, Danil Kurkin

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:

Description Danil Kurkin 2015-05-05 06:37:00 UTC
Xamarin for VS:

 Copying bin/iPhone/Debug/DriverNavigationApp.dll.mdb... (TaskId:167)
1>  Copying bin/iPhone/Debug/DriverNavigationAppUnifiediOS.exe... (TaskId:167)
1>  MTouch: 2015-05-05T11:24:44.9204826+01:00 - Serializing intputs (TaskId:167)
1>  MTouch: 2015-05-05T11:24:44.9294826+01:00 - Executing (TaskId:167)
1>  Executing task: Xamarin.iOS.Tasks.MTouch (TaskId:167)
1>  Server returned an error. The underlying connection was closed: The connection was closed unexpectedly.
1>   (TaskId:167)
1>  Remote task execution failed. (TaskId:167)
1>  MTouch: 2015-05-05T11:25:08.0974826+01:00 - Finished (TaskId:167)
1>Done executing task "MTouch" -- FAILED. (TaskId:167)
1>Done building target "_CompileToNative" in project "DriverNavigationAppUnified.iOS.csproj" -- FAILED.: (TargetId:212)

or sometime throwing this error:

The type initializer for 'NuGet.EnvironmentUtility' threw an exception.
Comment 1 Danil Kurkin 2015-05-05 08:07:45 UTC
Downgrade Xamarin.iOS to 3.9 on Win and 8.9 on Mac helped
Comment 2 Sadik Ali 2015-05-06 10:43:06 UTC
I have checked this issue and unable to reproduce the above behavior. App is getting build and deploy successfully on device.

Screencast: http://www.screencast.com/t/sLhpKKogG

Please let me know if I missed any step.

Can you please Sample Application to reproduce the above behavior.

It would be great if you also provide Ide Logs,Build Output and Environment info. You get these information from
#Ide Logs:Help->Xamarin->Zip Xamarin Logs
#Environment Info:->Help->About Microsoft Visual Studio

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Professional

Xamarin   3.11.504.0 (37bb34c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (cbdf025e886eacb95ce7adf53346961156fae990)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS (7741cc495ab0baf04ff0405d0604bc27f0ecae2e)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration

Comment 3 Danil Kurkin 2015-05-19 04:50:52 UTC
Created attachment 11239 [details]
Done executing task "MTouch" -- FAILED

Failed to connect to Mac server
Comment 6 Uren Patel 2015-06-18 08:13:22 UTC
I am having the same issues. On my project I narrowed the problem down a custom UIButton class. 

I created a BorderedButton : UIButton class to add a border around regular buttons. Have this class included in the project (not necessarily being used) causes MTouch to disconnect from the server during the build process.
Comment 7 Jon Goldberger [MSFT] 2015-06-18 15:37:57 UTC
I suspect there  may be multiple reasons for this issue, but in the case noted above in private comment 4, and in public comment 6, the issue was with the Type registrar. When I added the BorderedButton custom control class noted in comment 6 above into an iOS project in both Visual Studio and Xamarin Studio, and then added the button to the storyboard, the project failed to deploy to device from both IDEs. The error message in Xamarin Studio was much more revealing in that it mentioned an issue with the Type registrar, so I looked at the attributes and noted spaces in the Exported names for the Properties of the control:

[Export("Corner radius"), Browsable(true)]

[Export("Border color"), Browsable(true)]

[Export("Border width"), Browsable(true)]

Removing the spaces resolved the issue. 

I also noted that the connection from VS to the build host was killed every time I tried to deploy to device from VS when spaces were present in the Exported names of the customer control. 

So unless this turns out to be the underlying reason for the others who are hitting this bug, I will get a new bug filed for this space issue. I am not sure if spaces are meant to be allowed or not, but at least a better error message in Visual Studio would be helpful... and also it seems that it shouldn't kill the build host connection when ibtool fails.
Comment 8 Jon Goldberger [MSFT] 2015-06-18 15:41:52 UTC
Error message in Xamarin Studio when the spaces are present in the exported property names of the custom control:

>/Users/apple/Documents/Xamarin/XamSupport/Playground-iOSUnifiedUniversal/Playground-iOSUnifiedUniversal/MTOUCH: Error MT4109: Failed to compile the generated registrar code. Please file a bug report at http://bugzilla.xamarin.com (MT4109) (Playground-iOSUnifiedUniversal)
Comment 9 Jon Goldberger [MSFT] 2015-06-18 20:28:20 UTC
New bug report filed for the space in the Property for a Custom Control:
Comment 10 Jon Goldberger [MSFT] 2015-06-18 20:29:17 UTC
Oops, messed up link: https://bugzilla.xamarin.com/show_bug.cgi?id=31239
Comment 11 Joaquin Jares 2016-12-22 17:59:04 UTC
Based on comments, I'm closing this as duplicate of 31239

*** This bug has been marked as a duplicate of bug 31239 ***