Bug 16331 - Unable to debug in simulator, debug session aborts
Summary: Unable to debug in simulator, debug session aborts
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 1.8.x
Hardware: PC Windows
: High normal
Target Milestone: 1.10.x (VS2013+1)
Assignee: Marek Habersack
Depends on:
Reported: 2013-11-19 02:39 UTC by Jacco Rademaker
Modified: 2016-05-10 17:03 UTC (History)
16 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 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 Jacco Rademaker 2013-11-19 02:39:17 UTC
Last week I updated my development environment to the latest stable Xamarin editions.
Since then:
- I could not build my solution on the Mac and reinstalled the Mono platform
- I could not build my solution in Visual Studio and removed the .Net platform and Xamarin software, reinstalled .Net Framework 4.5, repaired my Visual Studio 2012 install, reinstalled Xamarin and paired Visual Studio with the Mac build server. Then got the latest Mono platform and also the new documentation.
Still no luck, Visual Studio had problems with my info.plist. Then removed the project, File -> new project, added all folders, files and dependencies and I had a build with Visual Studio.

But now I'm unable to start the simulator from Visual Studio. The debug session aborts immediately.
There is no problem when debugging with Xamarin Studio on the Mac.

This is the Visual Studio log:
Mono.IOS.VisualStudio.MonoTouchPackage Warning: 0 : Build server returned an Warning.
Mono.IOS.VisualStudio.MonoTouchPackage Warning: 0 : Negotiating server information for pairing process.
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\mscorlib\\mscorlib.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\\Microsoft.VisualStudio.HostingProcess.Utilities.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\\System.Windows.Forms.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System\\System.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Drawing\\System.Drawing.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\\Microsoft.VisualStudio.Debugger.Runtime.dll'
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Working\TroostwijkAuctions.Client\TroostwijkAuctions.Client.iOS\bin\iPhoneSimulator\Debug\Application.vshost.exe'
The thread 'vshost.NotifyLoad' (0x1908) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1a94) has exited with code 0 (0x0).
'Application.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Working\Applicataion\bin\iPhoneSimulator\Debug\Application.exe', Symbols loaded.
Getting device...
Starting debug on:iPhone 6.1
Remote build finished...
Debugging session ended.
Debugging session ended.
The program '[3524] Application.vshost.exe: Managed (v2.0.50727)' has exited with code -1 (0xffffffff).

What can I do next to get the debugging working again?
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2013-11-19 19:33:39 UTC
Hi! When you get a chance, if you wouldn't mind attaching your Xamarin log file [1], that would be perfect. You can mark the attachment private if you like, so only Xamarin team members will see it.

> [1] %LOCALAPPDATA%\Xamarin\Log\MonoTouchVS\[12.0|11.0|10.0]\Trace.[0|1|2].log

In particular, I suspect it might contain some lines that look like this:

> System.Net.WebException: The remote server returned an error: (429).
>    at System.Net.HttpWebRequest.GetResponse()
>    at MonoTouch.Tools.Utilities.BuildServerClient.ServerIO.Server_Post[TResponse](String command, MemoryStream ms, IDictionary`2 queryVariables)
> Mono.IOS.VisualStudio.MonoTouchPackage Error: 0 : [2013-11-15 14:42:27.1] Server command 'SdkStatus': unable to retrieve status of the Xamarin.iOS SDK on the server
> No response received from the server

> System.Net.WebException: The remote server returned an error: (429).
>    at System.Net.HttpWebRequest.GetResponse()
>    at MonoTouch.Tools.Utilities.BuildServerClient.ServerIO.Server_GetResult[T](String command, IDictionary`2 queryVariables)
> Mono.IOS.VisualStudio.MonoTouchPackage Error: 0 : [2013-11-15 14:42:32.1] Xamarin.iOS encountered the following error(s):
> System.Exception: Failed to clean build cache on the server (Generic)
> Server command 'CleanRemoteCache': failed to clean build cache on the server

If you see these lines, then I think you're hitting the same issue from these:

> https://bugzilla.xamarin.com/show_bug.cgi?id=16242
> http://forums.xamarin.com/discussion/10193/deployement-on-ios-device-fail-error-429
> http://forums.xamarin.com/discussion/comment/34925/#Comment_34925

For the other users in the forums, downgrading to the previous stable versions (see [2]) has worked as a way to avoid the problem temporarily until the bug is fixed.

> [2] http://forums.xamarin.com/discussion/comment/34925/#Comment_34925
Comment 3 Jacco Rademaker 2013-11-20 05:30:04 UTC
I added the log.
I think there's a different problem than the one you were expecting.

I'm also not able to show the Simulator by means of the button in Visual Studio.
And I am able to download the new documentation, but is does not install, as I keep getting prompted.
I will also add the Mac Server Log.
Comment 5 Mohit Kheterpal 2013-11-20 10:11:41 UTC
Thank you Jacco for responding with the log files.
Comment 6 Miguel de Icaza [MSFT] 2013-11-26 17:11:23 UTC
Which version of Xcode is running on the Mac?
Comment 7 Jacco Rademaker 2013-11-26 17:37:14 UTC
Xcode 4.6.3 (2068) Build 4H1503

I also installed the new Xamarin Studio Beta today on the Mac.
Then I did see a warning (twice) in Visual Studio that did indicate my PC was unable to determine the status of the Xamarin.iOS SDK on the server.

So it might after all be the same problem as (or closely related to) the issue Brendan stated in comment 1?
Comment 8 Hugo 2013-12-02 19:20:21 UTC
I've also had this problem since last week, and found an unlikely fix. I opened the solution on Xamarin on the mac, and found several errors: some files that I had deleted but not properly excluded from the project were giving it trouble, and prevented the app from debugging.

However, these missing files were not giving any errors or warnings in Visual Studio. Once I fixed these reference errors the solution would build again on the mac, and also through the Visual Studio plugin.

Try launching your solution on Xamarin on your mac and see whether it gives any errors.
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2013-12-02 23:41:19 UTC
@Hugo, thanks for the nice find on using Xamarin Studio to fix up projects!

Just in case that doesn't solve the problem for anyone who's looking at this bug, it turns out, there is yet another cause of the "debugging session quits immediately" problem. You can check if you're hitting this problem by looking in the logs on the Mac build host:

> ~/Library/Logs/Xamarin/MonoTouchVS

In addition to the `mtbserver.log` and `mtbservergui.log`, this folder contains individual logs for the apps you have built. After opening the log corresponding to the app that has been failing to deploy, search for "error MT2002: Failed to resolve assembly." If you see this error, then you are very likely hitting this bug:

> MSBuild Resolver is not picking up the full listing of all N-th order assembly dependencies

You can work around the problem by adding all of the dependencies from each of the library projects to the app project (or unit test project). This is a messy workaround because once the bug fix is released, you can go back and remove all of those dependencies. The bug has indeed been corrected in Xamarin.iOS version 1.10, which should be available from the Alpha channel soon.
Comment 10 Graham Moore 2013-12-03 04:42:19 UTC
I also had the instant debug session termination problem on Visual Studio. Turned out to be another variation of the problem reported by @Hugo.

I had deleted some resource files from my Visual Studio project. However they were not fully removed from the project. Opening and trying to build in XS revealed the "missing" files. Deleting these from the project in XS allowed the build to work on VS.

More flakiness in the VS extension. More lost time with random errors which just appear. Makes one seriously question the value of the licence fee for VS.
Comment 11 Dominique Louis 2013-12-03 16:14:45 UTC
Hi Jacco, Graham and Hugo,
  Were the deleted resources in the top level directory or inside the Resources folder, or did it not matter?

Comment 12 Hugo 2013-12-03 17:14:09 UTC
@Dominique: They were in a different folder than Resources: [root]/Content/Textures/UI/

I'd also like to note that the missing files/folder were not showing up in Xamarin Studio (it was just giving me the errors about them) - I had to remove the references in VS2012.
Comment 13 Graham Moore 2013-12-03 17:18:33 UTC
@Dominique mine were in the Resources folder. They didn't initially appear in Xamarin Studio until I tried to run a build then got the errors and they appeared as missing in the project explorer.
Comment 14 Graham Moore 2013-12-03 17:18:49 UTC
I deleted mine from XS.
Comment 15 Graham Moore 2013-12-03 18:14:54 UTC
Aside from the actual bug in the project removal process, a big issue here is the reporting of useful error messages generally. I had a problem for a long time where breakpoints were never hit. It turned out to be something related to a native library I was linking in. There were no errors reported anywhere and the calls worked but debugging was pretty much disabled.
Comment 16 Dominique Louis 2013-12-04 10:31:43 UTC
Thanks for your replies.

@Graham, this is something we are aware of and are working to improve.
If you have a specific scenario that caused you confusion, could you please log a separate bugzilla, so we can track and prioritize it for a future release.
Comment 17 PJ 2013-12-04 11:35:46 UTC
As the 1.10 release is coming out to Beta today, we'll have to target this for the next release.
Comment 18 Brendan Zagaeski (Xamarin Team, assistant) 2013-12-04 12:17:31 UTC
A quick thought on error reporting, though it's probably already in the plans: if there's a way to display all of the error messages from the per-application .log files from `~/Library/Logs/Xamarin/MonoTouchVS/` in the Visual Studio output panels, that would be very helpful.
Comment 20 Graham Moore 2013-12-04 16:33:32 UTC
Hi @Dominique my specific case in this regard was that the Visual Studio build didn't report that project files were missing before activating the debug stage. I would expect all build errors to be reported at the time of build (C# build) and then not allowing the process to proceed to the debug stage. I haven't looked into the specifics of what was happening with the project file. It was strange that Xamarin Studio didn't report the missing files either until build but at least it picked it up on build. I was then able to correct the project and proceed back to a Visual Studio build.
Comment 21 Graham Moore 2013-12-04 16:36:06 UTC
Also to respond to the comment from @Brendan I did look in ALL the log files and there was an error but it gave me absolutely no clue on what the problem was. I only fixed it due to following the suggestions from @Hugo.
Comment 22 Jacco Rademaker 2013-12-05 04:48:17 UTC
@Brendan, I finally got to examine your suggestions in Comment 9.
This indeed is the issue I am experiencing.
Comment 23 Marek Habersack 2013-12-06 08:33:09 UTC
This bug is fixed in both master and 1.10 release branches. It should be part of the 1.10 release when it's out of beta (pending QA review).
Comment 26 Saurabh 2013-12-06 13:26:26 UTC
We have checked this issue with:

VS 2013
MTVS 1.10.29

After Creating an iOS project that has an image, we have rename one of the images in that folder from outside of IDE, then build the project.

Then it gives an  Error 2  Resource Resources/Default.png not found on disk (should be at c:\users\administrator\documents\visual studio 2013\Projects\HelloWorld76\HelloWorld76\Resources\Default.png) HelloWorld76

Hence marking this as Verified