Bug 56991 - Example scenario for error from Bug 56787 "Could not load file or assembly 'Mono.Posix, Version=2.0.0.0, ...'" when attempting to start debugging with breakpoints set
Summary: Example scenario for error from Bug 56787 "Could not load file or assembly 'M...
Status: RESOLVED DUPLICATE of bug 56787
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 4.5.0 (15.2)
Hardware: PC Mac OS
: --- critical
Target Milestone: 15.3
Assignee: Bugzilla
URL:
Depends on:
Blocks: 56787
  Show dependency tree
 
Reported: 2017-05-31 04:43 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2017-06-27 19:27 UTC (History)
6 users (show)

Tags: xamextfollowed
Is this bug a regression?: Yes
Last known good build: XamarinVS 4.5.0.451 (ff04dcc)


Attachments
Test case (160.76 KB, application/zip)
2017-05-31 04:43 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Example assembly binding log (from `fuslogvw`) (13.36 KB, text/plain)
2017-05-31 04:44 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Mono.Posix.dll file for temporary workaround (183.51 KB, application/x-msdownload)
2017-05-31 04:46 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 DUPLICATE of bug 56787

Description Brendan Zagaeski (Xamarin Team, assistant) 2017-05-31 04:43:19 UTC
Created attachment 22569 [details]
Test case

Example scenario for error from Bug 56787 "Could not load file or assembly 'Mono.Posix, Version=2.0.0.0, ...'" when attempting to start debugging with breakpoints set




## Regression status: regression in XamarinVS 4.5.0.476 (1be4f0c) compared to XamarinVS 4.5.0.443 (c871575)

BAD:  XamarinVS 4.5.0.476 (1be4f0c) "15.2.2 release"
BAD:  XamarinVS 4.5.0.455 (3c254b0) [*]
GOOD: XamarinVS 4.5.0.451 (ff04dcc) [*]
GOOD: XamarinVS 4.5.0.443 (c871575) "15.2 release"


[*] Un-published development builds, tested using the Visual Studio 2015 Update 3 .msi installation workflow for the closest similarity to end-user installation scenarios.




## Steps followed to test

1. Start with a clean Windows 10 image with a fresh installation of Visual Studio 2017 version 15.2 (26430.12) and the "Mobile development with .NET" workload.  (It probably isn't strictly required for the Windows image to be brand new for these steps to work.)

2. Unzip the attached test case.  For my tests, I unzipped the project into C:\source.

3. Open the attached test case in Visual Studio.  Be sure _not_ to delete the hidden .vs directory.  This particular test scenario depends on the fact that the breakpoint currently set in MyClass.cs, line 10 does _not_ match the path of the file on disk [1].

4. Start debugging the Android app project in the "Debug|Any CPU" configuration on device or emulator.


[1] An alternative is to delete .vs directory, add a new breakpoint, quit Visual Studio, rename the top-level solution directory, and then reopen the solution.




## BAD Results with Xamarin.VisualStudio 4.5.0.476 (1be4f0c)

The application begins to run successfully, but then the app exits and an error message appears.  The logs indicate that this happens before the breakpoint is resolved.


- An error dialog appears in Visual Studio that shows an error message about the missing Mono.Posix assembly on the development computer:
> EXCEPTION: Mono.Debugging.Soft.DisconnectedException: The connection with the debugger has been lost. The target application may have exited. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified.
>    at Mono.Debugging.Soft.SoftDebuggerSession.ResolveSymbolicLink(String path)
>    at Mono.Debugging.Soft.SoftDebuggerSession.PathsAreEqual(String p1, String p2)
>    at Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByMethod(MethodMirror method, String file, Int32 line, Int32 column, Boolean& insideTypeRange)
>    at Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByType(TypeMirror type, String file, Int32 line, Int32 column, Boolean& genericMethod, Boolean& insideTypeRange)
>    at Mono.Debugging.Soft.SoftDebuggerSession.ResolveBreakpoints(TypeMirror type)
>    at Mono.Debugging.Soft.SoftDebuggerSession.HandleTypeLoadEvents(TypeLoadEvent[] events)
>    at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es)
>    at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler()
> 

- The "View > Output > Debug" window shows the same exception message plus one additional preceding message:

> The connection with the debugger has been lost. The target application
> may have exited.

- The Assembly Binding Log (`fuslogvw`) collected using the steps from Bug 56839, Comment 10 shows that devenv.exe searches several locations but is unable to locate Mono.Posix.dll (see attached `fuslogvw` log file).




## GOOD Results with Xamarin.VisualStudio 4.5.0.443

The app launches successfully, and then the debugger breaks on the breakpoint.




## Testing environment info (brief)

Microsoft Visual Studio Enterprise 2017
Version 15.2 (26430.12) Release

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3

Microsoft .NET Framework
Version 4.7.02046

Java JDK 8u131 (1.8.0_131) 64-bit

Android SDK Tools 25.2.5
Android SDK Platform-tools 25.0.3
Android SDK Build-tools 23.0.3

Android 7.1.1 (API 25) SDK Platform rev. 3

Windows 10 version 1703 (OS Build 15063.296)
US English locale, US Eastern time zone



### Devices tested

Google API 23 (x86) emulator
Moto G3 API 23 device
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-31 04:44:16 UTC
Created attachment 22570 [details]
Example assembly binding log (from `fuslogvw`)
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-31 04:46:09 UTC
Created attachment 22571 [details]
Mono.Posix.dll file for temporary workaround

## Possible temporary workaround

(This workaround was effective in my local testing for the precise scenario described in Comment 0, but as hinted at in Bug 56787, Comment 29, there might also be some other different scenarios that can cause this issue that will not be resolved by this workaround.)


1. Download the attached Mono.Posix.dll file.  (This files is signed with a Xamarin code signature.)


2a. For Visual Studio 2017, copy the file into the "Xamarin.VisualStudio" extension directory.  For a default installation of the Enterprise edition this will be:
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Xamarin.VisualStudio

2b. For Visual Studio 2015, copy the file into the "Xamarin\Xamarin" extension directory:
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\
Comment 3 Joaquin Jares 2017-06-02 16:19:50 UTC

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