This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 56787 - [15.2.2] "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." when attempting to start apps
Summary: [15.2.2] "System.IO.FileNotFoundException: Could not load file or assembly 'M...
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General (show other bugs)
Version: 4.5.0 (15.2)
Hardware: PC Windows
: --- critical
Target Milestone: 15.3
Assignee: Bugzilla
URL:
: 56839 56991 57034 58288 (view as bug list)
Depends on: 56991 57034 57420
Blocks:
  Show dependency tree
 
Reported: 2017-05-24 09:09 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2017-07-21 19:08 UTC (History)
42 users (show)

See Also:
Tags: xamexttriage
Is this bug a regression?: Yes
Last known good build: Xamarin.VisualStudio 4.5.0.443


Attachments
Mono.Posix.dll file for temporary workaround (183.51 KB, application/x-msdownload)
2017-05-26 20:27 UTC, Brendan Zagaeski (Xamarin Support)
Details
Mono.Posix.dll file for temporary workaround (183.51 KB, application/x-msdownload)
2017-06-02 15:02 UTC, Brendan Zagaeski (Xamarin Support)
Details

Description Brendan Zagaeski (Xamarin Support) 2017-05-24 09:09:17 UTC
## Copying Bug 56275, Comment 154 from Michel Moorlag to set up an investigation for a reported issue on the 4.5.0.475 service release build

I am using using Visual Studio 2015 update 3 and Xamarin 4.4.0.34. This morning I verified I was able to build and debug on both Android and IOS. Then I fired up Xamarin Studio Community on my Mac and searched for updates. I downloaded and installed all the updates available. Then I installed Xamarin 4.5.0.475 on my windows pc with Visual Studio. I rebooted my machine and cleaned my solution. I uninstalled my app from my Android phone. The good news is that I can build without any lockup for both Android and IOS. The bad news is that I can not debug anymore on both Android as IOS. The app gets deployed and I see the splashscreen. Halfways the app stops and I receive an error in visual studio.
I am seeing files not found exceptions like file Mono.Posix ?

I and the relevant part form my logging for Android:

Thread started:  #9
InspectorDebugSession(6): HandleTargetEvent: ThreadStarted
05-24 09:51:00.943 D/Mono    (23385): Image addref System.ComponentModel.TypeConverter[0xb875a398] -> System.ComponentModel.TypeConverter.dll[0xb923d9c0]: 2
05-24 09:51:00.943 D/Mono    (23385): Prepared to set up assembly 'System.ComponentModel.TypeConverter' (System.ComponentModel.TypeConverter.dll)
05-24 09:51:00.943 D/Mono    (23385): Assembly System.ComponentModel.TypeConverter[0xb875a398] added to domain RootDomain, ref_count=1
05-24 09:51:00.954 D/Mono    (23385): AOT: image 'System.ComponentModel.TypeConverter.dll.so' not found: dlopen failed: library "/data/app/com.fullwood.crystalx3-1/lib/arm/libaot-System.ComponentModel.TypeConverter.dll.so" not found
05-24 09:51:00.963 D/Mono    (23385): AOT: image '/usr/local/lib/mono/aot-cache/arm/System.ComponentModel.TypeConverter.dll.so' not found: dlopen failed: library "/data/app/com.fullwood.crystalx3-1/lib/arm/libaot-System.ComponentModel.TypeConverter.dll.so" not found
05-24 09:51:00.963 D/Mono    (23385): Config attempting to parse: 'System.ComponentModel.TypeConverter.dll.config'.
05-24 09:51:00.964 D/Mono    (23385): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.config'.
05-24 09:51:00.964 D/Mono    (23385): Assembly Ref addref Newtonsoft.Json[0xb83dc090] -> System.ComponentModel.TypeConverter[0xb875a398]: 2
05-24 09:51:00.964 D/Mono    (23385): Assembly Ref addref System.ComponentModel.TypeConverter[0xb875a398] -> System[0xb876b048]: 10
Loaded assembly: System.ComponentModel.TypeConverter.dll [External]
05-24 09:51:01.004 D/Mono    (23385): Assembly Ref addref CrystalLight.Droid[0xb83c2940] -> Akavache[0xb83c6728]: 4
05-24 09:51:01.014 D/Mono    (23385): Assembly Ref addref CrystalLight.Droid[0xb83c2940] -> System.Reactive.Linq[0xb83f1628]: 6
05-24 09:51:01.014 D/Mono    (23385): Assembly Ref addref CrystalLight.Droid[0xb83c2940] -> System.Reactive.Core[0xb83ef980]: 6
05-24 09:51:01.015 D/Mono    (23385): Assembly Ref addref CrystalLight.Droid[0xb83c2940] -> FreshMvvm[0xb83d3df8]: 3
05-24 09:51:01.035 V/MyBroadcastReceiver-GCM(23385): GCM Registered: APA91bG9c6MzE1iSnzVj2DRWenPAHV_ETVj3pItsGEpsoJPSnpoNy0V5pAl3UAzPIYqJjJl3-LB8OTxCnp2KT9CHRDOIhg9uB05BlsIwZvAx1NKIBFH-fDiV-y7IQux9gUNJNQJdcbxM
05-24 09:51:01.036 D/Mono    (23385): Assembly Ref addref CrystalLight.Droid[0xb83c2940] -> Xamarin.Azure.NotificationHubs.Android[0xb8408bc0]: 2
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.
File name: 'Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
   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()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

InspectorDebugSession(6): HandleTargetEvent: TargetExited
InspectorDebugSession(6): Disposed


And for IOS is see something about a broken mono install?
Launching 'CrystalLight.iOS' on 'iPhone 5s iOS 10.3'...
Loaded assembly: /Users/mhgmoorlag/Library/Developer/CoreSimulator/Devices/F57843E5-DC9F-4B17-B172-4DD0A637DA87/data/Containers/Bundle/Application/124034C5-71D4-4486-9100-BFBF1EBB709B/CrystalLight.iOS.app/.monotouch-64/Xamarin.iOS.dll [External]
2017-05-24 09:41:57.068 CrystalLight.iOS[79924:22793982] warning: cant resolve internal call to "System.Threading.Thread::CurrentInternalThread_internal()" (tested without signature also)
2017-05-24 09:41:57.070 CrystalLight.iOS[79924:22793982] 
Your mono runtime and class libraries are out of sync.
2017-05-24 09:41:57.071 CrystalLight.iOS[79924:22793982] The out of sync library is: /Users/mhgmoorlag/Library/Developer/CoreSimulator/Devices/F57843E5-DC9F-4B17-B172-4DD0A637DA87/data/Containers/Bundle/Application/124034C5-71D4-4486-9100-BFBF1EBB709B/CrystalLight.iOS.app/.monotouch-64/mscorlib.dll
2017-05-24 09:41:57.071 CrystalLight.iOS[79924:22793982] 
When you update one from git you need to update, compile and install
the other too.
2017-05-24 09:41:57.072 CrystalLight.iOS[79924:22793982] Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
2017-05-24 09:41:57.072 CrystalLight.iOS[79924:22793982] If you see other errors or faults after this message they are probably related
2017-05-24 09:41:57.073 CrystalLight.iOS[79924:22793982] and you need to fix your mono install first.
Loaded assembly: /Users/mhgmoorlag/Library/Developer/CoreSimulator/Devices/F57843E5-DC9F-4B17-B172-4DD0A637DA87/data/Containers/Bundle/Application/124034C5-71D4-4486-9100-BFBF1EBB709B/CrystalLight.iOS.app/.monotouch-64/System.dll [External]
Thread started:  #2
2017-05-24 09:41:57.396 CrystalLight.iOS[79924:22794211] critical: Stacktrace:
2017-05-24 09:41:57.397 CrystalLight.iOS[79924:22794211] critical: 
Native stacktrace:
2017-05-24 09:41:57.460 CrystalLight.iOS[79924:22794211] critical: 	0   CrystalLight.iOS                    0x000000010e8c1191 mono_handle_native_crash + 257
2017-05-24 09:41:57.460 CrystalLight.iOS[79924:22794211] critical: 	1   CrystalLight.iOS                    0x000000010e8ce260 mono_sigsegv_signal_handler + 288
2017-05-24 09:41:57.461 CrystalLight.iOS[79924:22794211] critical: 	2   libsystem_platform.dylib            0x000000011bd66bba _sigtramp + 26
2017-05-24 09:41:57.461 CrystalLight.iOS[79924:22794211] critical: 	3   ???                                 0x0000000000000000 0x0 + 0
2017-05-24 09:41:57.462 CrystalLight.iOS[79924:22794211] critical: 	4   CrystalLight.iOS                    0x000000010ea0fd39 finish_gray_stack + 121
2017-05-24 09:41:57.462 CrystalLight.iOS[79924:22794211] critical: 	5   CrystalLight.iOS                    0x000000010ea10594 major_finish_collection + 132
2017-05-24 09:41:57.462 CrystalLight.iOS[79924:22794211] critical: 	6   CrystalLight.iOS                    0x000000010ea0ca60 major_do_collection + 160
2017-05-24 09:41:57.463 CrystalLight.iOS[79924:22794211] critical: 	7   CrystalLight.iOS                    0x000000010ea0bfd9 sgen_perform_collection + 713
2017-05-24 09:41:57.463 CrystalLight.iOS[79924:22794211] critical: 	8   CrystalLight.iOS                    0x000000010ea0d6d3 sgen_gc_collect + 51
2017-05-24 09:41:57.464 CrystalLight.iOS[79924:22794211] critical: 	9   CrystalLight.iOS                    0x000000010ea84ad6 _ZL7pump_gcPv + 54
2017-05-24 09:41:57.464 CrystalLight.iOS[79924:22794211] critical: 	10  libsystem_pthread.dylib             0x000000011bd78aab _pthread_body + 180
2017-05-24 09:41:57.464 CrystalLight.iOS[79924:22794211] critical: 	11  libsystem_pthread.dylib             0x000000011bd789f7 _pthread_body + 0
2017-05-24 09:41:57.465 CrystalLight.iOS[79924:22794211] critical: 	12  libsystem_pthread.dylib             0x000000011bd781fd thread_start + 13
2017-05-24 09:41:57.465 CrystalLight.iOS[79924:22794211] critical: 
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
The app has been terminated.
Launch failed. The app 'CrystalLight.iOS' could not be launched on 'iPhone 5s iOS 10.3'. Error: An error occurred while executing MTouch. Please check the logs for more details.
The app has been terminated.


Further I noticed after deploy and crash of the android app I can start it manually on my phone and the app seems to function correct. The IOS can't be started manually though.
Comment 1 Brendan Zagaeski (Xamarin Support) 2017-05-24 09:10:51 UTC
## Copying Bug 56275, Comment 155 from softlion for additional report of the issue

On Android debugging on simulator now fails and triggers this:

---------------------------
Microsoft Visual Studio
---------------------------
EXCEPTION: Mono.Debugging.Soft.DisconnectedException: The connection with the debugger has been lost. The target application may have exited. ---> System.IO.FileNotFoundException: Can not load 'Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or its dependencies. File not found.

   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()

   --- End of inner exception stack trace ---
---------------------------
OK   
---------------------------
Comment 2 Michel Moorlag 2017-05-24 09:27:00 UTC
Additional info:

I rolledback to 4.4.0.34 (again). On my Mac I downloaded and installed Xamarin iOS 10.8 but I still got the "broken mono install" error. So I reinstalled mono and now everything is working fine (again).

Now I am not sure if the IOS problem was caused by Xamarin 4.5.0.475 or it might have been a corrupted mono install. But the Android Mono.Posix problem is definitely introduced with Xamarin 4.5.0.475.

@softlion, seems I have exact the same error as you do. Can you build and debug for IOS?
Comment 3 softlion 2017-05-24 11:05:06 UTC
Additional info:
i cleaned the solution, deleted bin/obj folders, removed mono runtimes and app from the android simulator, without success.
I came back after letting the PC alone 1h. 
Now it debugs fine !
Crazy ...


For iOS: not tryed yet. I have to finish something today on android first.


Note that each time i update Xamarin on Windows (last 6 months), the VS2015 plugin is broken. I have to do a "Repair" to get it working fine again.
This week's update have the same problem.
Even the recent switch to Windows 10 Creator Update (15063.296 version 1703) didn't fix it.
Comment 4 softlion 2017-05-24 11:11:48 UTC
Adding a breakpoint while in a successful debugging session does trigger the message i reported in comment1.
Comment 5 Michel Moorlag 2017-05-24 11:21:30 UTC
I didn't try but it seems there is a Mono.Posix 2.0 nugget package for the missing Mono.posix file? 
See https://office.dasz.at/ngf/packages/Mono.Posix/
Would that fix it?
Comment 6 Joaquin Jares 2017-05-24 13:03:13 UTC Comment hidden (obsolete)
Comment 7 softlion 2017-05-24 13:13:28 UTC
I have 2 already:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\g2bh5grb.jql\Mono.Posix.dll
dated 2016/11/30 09:59
version 2.0.0.0
signed 2016/11/08

Another one in
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\htsrwpq3.ff0
dated 2016/11/19 14:21
version 2.0.0.0
signed 2016/11/08

Maybe i should remove one ?
Comment 8 Joaquin Jares 2017-05-24 13:48:01 UTC
they are the same, though... what else do you have in those folders? Maybe you ended up with two copies of the debugger and that's what's producing conflicts.
Comment 9 Michel Moorlag 2017-05-24 14:26:22 UTC
I have one: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\Mono.Posix.dll

File version 2.0.0.0
Product verion 2.0.0.0
Size 183 KB
Date Modified 30-3-2017 11:03
Comment 10 Joaquin Jares 2017-05-24 14:44:57 UTC
@Michael, do you have Mono Debugging for Visual Studio in your Extensions and Updates? I just checked and what softlion is seeing is correct: there's one in our main extension and one in the debugger.
Comment 11 Michel Moorlag 2017-05-24 14:49:02 UTC
@ Joaquin
Yes I have "Mono Debugging for Visual Studio" version 1.0.41 in my list of installed extensions. Date installed is today. Maybe I added it to my path env var?
Comment 12 softlion 2017-05-24 15:06:33 UTC
I installed mono for windows.
Version 32bits: no luck, same behavior.
Version 64bits: no luck, same behavior.

I also have "Mono Debugging for Visual Studio".

Note that i also have VS2017 on the same machine.
Comment 13 Michel Moorlag 2017-05-24 19:10:30 UTC
I also have Vs2017 15.1 on the same machine.
Comment 14 Brendan Zagaeski (Xamarin Support) 2017-05-24 19:31:13 UTC
## Preliminary confirmation attempts

I attempted to replicate this error "Could not load file or assembly 'Mono.Posix...'" using a couple different upgrade paths to Xamarin.VisualStudio 4.5.0.475, from either 4.4.0.34 or 4.5.0.443.

So far unfortunately I haven't been able to hit the error, suggesting that there are some details I overlooked that are needed to hit the `ResolveSymbolicLink()` code path.

But in the end, it looks like reproducing the error is not immediately necessary.  Inspection of the installer packages suggests that issue is just that the 4.5.0.475 installer does not install the Mono.Posix.dll to the expected location.  I will tentatively set the bug status to CONFIRMED based on this result.




## Indications of a packaging issue

> With                    Xamarin.VisualStudio 4.4.0.34 : "Extensions\Xamarin\Xamarin\Mono.Posix.dll" exists.
> If I update 4.4.0.34 to Xamarin.VisualStudio 4.5.0.443: "Extensions\Xamarin\Xamarin\Mono.Posix.dll" exists.
> If I update 4.4.0.34 to Xamarin.VisualStudio 4.5.0.475: "Extensions\Xamarin\Xamarin\Mono.Posix.dll" does _not_ exist.



A dump [1] of the .msi file contents for the 3 different installers shows a decreasing number of occurrences of Mono.Posix.dll:


### 4.4.0.34

0ucq5bcm.dll|Mono.Posix.dll
3haqpn1m.dll|Mono.Posix.dll
re8inkhh.dll|Mono.Posix.dll
tnjr-9b2.mdb|Mono.Posix.dll.mdb


### 4.5.0.443

gwt1bdtn.dll|Mono.Posix.dll
re8inkhh.dll|Mono.Posix.dll


### 4.5.0.475

re8inkhh.dll|Mono.Posix.dll



[1] https://www.hanselman.com/blog/HowToListAllTheFilesInAnMSIInstallerUsingVBSciript.aspx
Comment 15 Brendan Zagaeski (Xamarin Support) 2017-05-24 20:03:18 UTC
@softlion, if by chance you still have Xamarin.VisualStudio 4.5.0.475 installed (or @Michel if you don't mind trying temporarily updating again), as a quick way to sanity-check the theory, I'd be curious to double-check if adding the Mono.Posix.dll to the Xamarin extensiion folder resolves the issue for either of you.



- One way to get the "Mono.Posix.dll" is to back it up while you have 4.4.0.34 or 4.5.0.443 installed, and then copy it back into that folder after updating to 4.5.0.475.

The source and destination directory to copy from and back to is:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\



- Another way to get the file (if you currently have 4.5.0.475 installed) is to extract the 4.4.0.34 .msi on the command line in a cmd.exe command prompt:

msiexec /a Xamarin.VisualStudio_4.4.0.34.msi /qb TARGETDIR=C:\Temp\Xamarin



Many thanks in advance!
Comment 16 softlion 2017-05-24 21:12:14 UTC
It works !
Thank you Brendan !!

File copied from 

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\g2bh5grb.jql

to

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin
Comment 17 Brendan Zagaeski (Xamarin Support) 2017-05-24 23:08:08 UTC
Excellent.  Thanks for the check!
Comment 18 Michel Moorlag 2017-05-25 06:22:05 UTC
I started from Xamarin 4.4.0.34. I had one mono.posix.dll in location C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin. Then I upgraded to Xamarin 4.5.0.475 and checked for mono.posix.dll again and it was gone. No more mono.posix.dll to be found in the extensions folders. Also the error from the description was back when I tried to debug. Then I closed VS, copied mono.posix.dll from my backup location to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin. I reopened my solution and now the problem was gone! So I can confirm that a copy of mono.posix.dll to the correct location fixes this problem. Thank you guys for you help, it's appreciated!

Two other observations I made:
1. This problem seems only relevant on real android phones. It seems I can debug on the simulator without mono.posix.dll. I don't know why?

2. When I install Xamarin 4.5.0.475 and I try to load my XF solution the first time I get several times a warning "The Xamarin shell package did not load correctly" and the IOS and Android solutions are not loaded. They say incompatible. After reloading VS its fine.
Comment 19 softlion 2017-05-25 07:32:43 UTC
@Michel: 

1) i can't debug or add breakpoint to an android code while debugging if it manages to launch when this DLL is not there.

2) "The Xamarin shell package did not load correctly": this is the exact same problem i described at the end of comment 3. Repair the Xamarin installation and it is fixed. But repairing after each update is a pain ...
Comment 20 Brendan Zagaeski (Xamarin Support) 2017-05-25 15:10:20 UTC
*** Bug 56839 has been marked as a duplicate of this bug. ***
Comment 21 anton.duzenko@gmail.com 2017-05-25 15:27:23 UTC
So what do I do after the file copy? It still crashes for me (I did a rebuild as well).
Comment 22 Brendan Zagaeski (Xamarin Support) 2017-05-25 16:40:30 UTC
@anton, I'll reopen Bug 56839 and pick back up with you there for a bit more double-checking.  Thanks!
Comment 23 Brendan Zagaeski (Xamarin Support) 2017-05-26 20:27:29 UTC
Created attachment 22522 [details]
Mono.Posix.dll file for temporary workaround

## Possible temporary workaround

For a bit of additional convenience in case any other user's run into this issue, the missing Mono.Posix.dll file to try (signed with a Xamarin code signature) is attached to this comment.

1. Download the attached file.

2. Copy the file into the missing location:
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\


I will also be following up with some additional diagnostic steps in Bug 56839 to dig into cases where replacing the file in that location does not resolve the issue.
Comment 24 Michel Moorlag 2017-05-29 06:53:57 UTC
@softlion

When I have the "The Xamarin shell package did not load correctly" problem I restart Vs and then the problem usually has gone. I never repaired my vs.
Comment 25 softlion 2017-05-29 07:01:12 UTC
Ok, i already tryed this and it never worked. I'll retry it next time.
Comment 26 Michel Moorlag 2017-05-29 08:42:16 UTC
Sometimes it doesn't work and you have to restart again. And sometimes it comes back out of nowhere so maybe I'll try the repair option
Comment 27 Michel Moorlag 2017-05-29 12:13:57 UTC
I am now on Xamarin 4.5.0.476 (Vs 2015 update 3) and both Android and IOS builds work fine now. Thank you Brendan and the rest of the team.

@softlion. I had no "The Xamarin shell package did not load correctly" problem after installing 4.5.0.476. Did you?
Comment 28 softlion 2017-05-29 16:14:38 UTC Comment hidden (obsolete)
Comment 29 Joaquin Jares 2017-05-29 19:45:21 UTC Comment hidden (obsolete)
Comment 30 Onur 2017-05-30 06:31:44 UTC
Hi,
İ upgrade xamarin and i have same issue.
İ try commment 29 but not working.

i have added monoposix dll to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin folder and i change the config file but not working.
Comment 31 Joaquin Jares 2017-05-30 14:48:15 UTC
Fixed. The fix will be available in 15.3. I'll try to get a workaround before that for people here.
Comment 32 Joaquin Jares 2017-05-30 17:16:23 UTC
*** Bug 56839 has been marked as a duplicate of this bug. ***
Comment 33 steveo275 2017-05-30 20:13:20 UTC
Same issue.  29 does not fix.
Comment 34 Philipp Sumi 2017-05-30 22:54:33 UTC
FYI, this just messed up the latest 15.2 update, too.
Comment 35 steveo275 2017-05-31 01:35:15 UTC
Repairing 15.2 didn't work for me as some suggested.  Issue does not occur in 15.3 preview.
Comment 36 Onur 2017-05-31 06:06:33 UTC
hi i upgrada xamarin to version 15.3 but bug still exits.

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=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified.
File name: 'Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' ---> 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.
File name: 'Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
Comment 37 Amenti 2017-05-31 08:15:17 UTC
The workarounds don't work for me either. :(
Comment 38 Brendan Zagaeski (Xamarin Support) 2017-05-31 19:11:38 UTC
## Note to the Xamarin team

I have filed Bug 56991 as a companion to this bug to record details about one particular scenario that makes use of the `ResolveSymbolicLink()` method and tries to load the "Mono.Posix, Version=2.0.0.0" assembly.  Joaquin, feel free to add details about the before and after development build numbers (or similar) for the fix mentioned in Comment 31 onto that bug, and I can check the results for that particular scenario.  Thanks!




## General status update

Note that Comment 36 shows a slightly different error than Comment 0, Comment 1, or the title of the bug report.

In particular, Comment 36 is showing an error for "Mono.Posix, Version=4.0.0.0", whereas up until that comment, only "Mono.Posix, Version=2.0.0.0" appeared in the error messages.

I suspect that Joaquin's candidate fix as mentioned in Comment 31 might resolve the issue for that scenario and other remaining scenarios.  The candidate fix would by default be included in the 15.3 final release.  It will likely also be included in a future 15.3 preview release from sometime after Comment 31 (2017-05-30).  But in the mean time, I would be happy to help look into 1 or 2 particular example scenarios from users to see what might be different compared to Comment 18, Comment 19, and Bug 56991 (where the workaround from Comment 23 was successful).




## For users, possible next steps after trying the workaround

For any 1 or 2 users who might be interested in trying additional troubleshooting for possible workarounds before the next 15.3 update, please complete the following steps:


1. If you have applied the devenv.exe.config file change from Comment 29, undo it to get back to a more "default" state.


2. Download the Mono.Posix.dll file from Comment 23.  (This files is signed with a Xamarin code signature.)


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

3b. 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\

4. Open `regedit` and navigate to the "HKEY_LOCAL_MACHINE\Software\Microsoft\Fusion" key.


5. Select "Edit > New > DWORD (32-bit) Value", name the value "EnableLog", and set the Data to 1.  (Or if the "EnableLog" value already exists, set the Data to 1.)


6. Quit and reopen Visual Studio.


7. Replicate the error one more time by debugging the app.


8. The "View > Output > Debug" output should now show a section that starts with "=== Pre-bind state information ===".


9. Create a new bug report.  You can use the following title:
"User scenario for Bug 56787 "Could not load file or assembly 'Mono.Posix...'" when attempting to start debugging with breakpoints set"

And the following description:
"I am filing this bug to provide details about one user scenario related to Bug 56787 that was not resolved by the workarounds on that bug report."


10. Attach the Debug output from step 9 to the new bug report, being sure to include the "Could not load file or assembly..." error message as well as all of the information after the "=== Pre-bind state information ===" message.  For example, you can use the "File > Save Output As" command to save the information to a .txt file and add that file as an attachment on the new bug report.


11. Add the number "56787" into the "Blocks" field for your bug, and save the change (or just leave a comment back on this bug that mentions the new bug number).


12. Switch back to `regedit`, Delete the "EnableLog" value from the registry (or set the value back to 0), and quit and reopen Visual Studio once more to turn off the extra logging.



Thanks in advance!
Comment 39 Marcin Wieczorek 2017-06-01 06:54:44 UTC
Brendan, I created the bug 57034 with requested log attached
Comment 40 Josemari 2017-06-01 11:09:34 UTC
I solved this issue downloading the Mono.Posix.dll file from Comment 23 and allow to Visual Studio to load remote sources, including the following lines in devenev.exe.config:

<runtime>
    <loadFromRemoteSources enabled="true"/>
</runtime>

I have Visual Studio 2015 Enterprise
Comment 41 David Pells 2017-06-01 12:00:48 UTC
I have copied the dll from comment 29 to;

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Xamarin.VisualStudio

I still recieved the problem. I then added the config entry from comment 40 and this now seems to be working

I'm on VS2017 PRO
Comment 42 Marcin Wieczorek 2017-06-01 13:20:22 UTC
Instead of changing global config you can also go to downloaded Mono.Posix.dll (in Windows Explorer), open its properties and in Global tab on the bottom you should see security warning ("This file came from another computer and might be blocked...". On the right side of the warning there is a checkbox "Unblock" - if you will mark it and press "Apply" then you shouldn't be forced to change global config of visual studio.
I tried it and the expeption on startup in debug mode is gone now. Anyway I cannot say that debugging of iOS devices on Windows works properly - I noticed, that the VS doesn't stop on lot of my breakpoints. When I am trying the same code with same breakpoints on MacOS (with Visual Studio for Mac) I can see that it recognizes breakpoints properly, on Windows it just does nothing for them. In my spare time I will check if there is any similar bug already reported, or if I could reproduce it on some simple project which I could share.
Comment 43 veruska_silva 2017-06-01 15:17:30 UTC
The workarounds explained in Comment 29 and Comment 42 worked for me.

Here are the steps:

1. Close Visual Studio.

2. Copy Mono.Posix.dll into C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin

3. Open Mono.Posix.dll properties and mark the checkbox "Unblock" in "General" tab. Then click "Apply" and "OK".

4. Reopen Visual Studio.

5. Clean and Rebuild solution.


I'm using VS2015 Professional here. Tested with an Xamarin.iOS project.
Comment 44 jz@jstartups.com 2017-06-01 15:32:48 UTC
I have the same issue. what I use is VS2017
Comment 46 Brendan Zagaeski (Xamarin Support) 2017-06-01 16:12:33 UTC
## Bookkeeping note

I have marked Comment 45 as non-public to keep the public-facing bug report a bit easier to read.  That comment does not provide any new information compared to Comment 0 and Comment 1, it does not take into account the prior discussion in Comment 38 through Comment 43, and it contains a large amount of stack trace text that makes the bug report more difficult to read.  Thanks!
Comment 47 Brendan Zagaeski (Xamarin Support) 2017-06-01 21:54:47 UTC
*** Bug 57034 has been marked as a duplicate of this bug. ***
Comment 48 Suat Korkmaz 2017-06-02 10:20:14 UTC
I've updated Xamarin to the latest stable for VS2015. No matter what I do I keep getting this error. I haven't had this problem before. I think it is something to do with the latest Xamarin.
Comment 49 Suat Korkmaz 2017-06-02 10:21:11 UTC
And here's my thread on Xamarin forums.

https://forums.xamarin.com/discussion/comment/277813#Comment_277813
Comment 50 Nikita Leshchev 2017-06-02 10:26:58 UTC
Worked for me. VS2017 Community
Comment 51 Philipp Sumi 2017-06-02 12:03:17 UTC
The step described in comment 43 didn't do it for me (I'm on Android though). Still can't debug. And deploying APKs to the emulator has been broken for me for ages :/
Comment 52 jz@jstartups.com 2017-06-02 13:28:22 UTC
I did anything I could based on information in the report. but no luck. it really impact our work.
Comment 53 Onur 2017-06-02 13:53:53 UTC
hi suat,
my problem is solved. I use visual studio 2015.



1. Copy Mono.Posix.dll into C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin

2. Open Mono.Posix.dll properties and mark the checkbox "Unblock" in "General" tab. Then click "Apply" and "OK".
3. change deven.exe.config

path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\deven.exe.config 
add this property
<runtime>
    <loadFromRemoteSources enabled="true"/>
</runtime>

4. close and Reopen Visual Studio.
Comment 54 Suat Korkmaz 2017-06-02 14:15:35 UTC
Onur,

I've found 5 Mono.Posix.dll in my C drive and they are all different sized and versioned. Which one should I use?
Comment 55 Suat Korkmaz 2017-06-02 14:17:49 UTC
By the way, there is no "Unblock" option in the properties of the Mono.Posix.dll file.
Comment 56 jz@jstartups.com 2017-06-02 14:27:36 UTC
I did the same as you did, except I use Visual Studio 2017. but not working
Comment 57 Suat Korkmaz 2017-06-02 14:29:11 UTC
I have both 2015 and 2017. Neither are working.
Comment 58 jz@jstartups.com 2017-06-02 14:37:10 UTC
I means same as Comment 53
Comment 59 Brendan Zagaeski (Xamarin Support) 2017-06-02 15:02:07 UTC
Created attachment 22656 [details]
Mono.Posix.dll file for temporary workaround

I see that some of the above recent comments are not following exactly the correct steps to test the workaround.

The investigation on this exact bug report can be considered closed at this time.  The particular issue tracked by this exact bug report is that the installer for the Xamarin 15.2.2 release in Visual Studio is missing the expected Mono.Posix.dll file in the expected location.

If the workaround below does not resolve the issue for some user's environment, you will need to collect the detailed logging Fusion logging information as described in Comment 38 (steps 4 through 12) and attach that information to a _new_ bug report for further investigation.  Thanks in advance!




## Workaround for this exact bug report


1. Ensure that you have _not_ added any binding redirects for Monos.Posix.dll to your devenv.exe.config file.  (Note that I have marked Comment 29 _obsolete_ because adding that binding redirect will by default _break_ this workaround.)


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


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

3b. 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\

4. Right-click the file in Explorer and select "Properties".


5. At the bottom of the General tab, if an "Unblock" checkbox is present, enable it and select "OK".  (The presence or absence of this checkbox depends in part on how the file was downloaded.)
Comment 60 Suat Korkmaz 2017-06-02 15:08:27 UTC
Comment on attachment 22656 [details]
Mono.Posix.dll file for temporary workaround

Brendan thanks.

Where is the original file located?
Comment 61 Brendan Zagaeski (Xamarin Support) 2017-06-02 15:15:50 UTC
I'm not sure I understand the question.  The missing file is the file in attachment 22656 [details].  It will otherwise be missing from your computer if you have the Xamarin 15.2.2 release installed because the Xamarin 15.2.2 installer unfortunately does not include the file, and that is the cause of this bug.  If you prefer, you could extract the file from one of the older Visual Studio 2015 .msi packages (as mentioned in Comment 15, see also [1]), but that will just give you the same file that is in attachment 22656 [details].

[1] https://kb.xamarin.com/customer/portal/articles/1699777-older-downloads
Comment 62 Jeff Gonzales 2017-06-02 15:23:54 UTC
I copy the Mono.Posix.dll file into my Extensions folder and the debugger no longer crashes upon startup when trying to debug an iOS application.  Unfortunately, the debugger doesn't stop on breakpoints and Visual Studio 2017 hangs when trying to press the "pause" button.

Is this related or a completely separate problem?  I tried repairing Visual Studio but to no avail.  I am able to debug with Android though.  What else can I try to fix this problem?
Comment 63 Brendan Zagaeski (Xamarin Support) 2017-06-02 15:28:18 UTC
> the debugger doesn't stop on breakpoints
> ...
> Is this related or a completely separate problem?

Yes, that is most likely a completely separate problem.  So far the most common cause I have seen for that symptom is Bug 56893, which includes a possible workaround.
Comment 64 Joaquin Jares 2017-06-02 16:19:50 UTC
*** Bug 56991 has been marked as a duplicate of this bug. ***
Comment 65 Marcin Wieczorek 2017-06-02 21:44:33 UTC
Just for the record, perhaps it will help someone. I faced both problems - Mono.Posix as well as ignoring breakpoints in PCL. Originally I worked with VS 2015 Enterprise + Xamarin stable. 
First I tried to switch to alpha version just to see if it helps, but as the current alpha doesn't have yet the fix it obviously didn't helped. Then I tried workarounds without success. In next step I switched to VS 2017 Enterprise and applied workaround right now described in comment 59. After this problem with Mono.Posix disappeated (in VS 2017). In next step I applied workaround for Bug 56893 and it seems that it solved my problems - now it stops on my breakpoints in PCL when debugging iPad device from VS2017. 

I tried to apply the same workarounds on VS 2015, but it doesn't work (still Mono.Posix exception). For now I will stay with VS 2017 and will see.
Comment 66 jz@jstartups.com 2017-06-02 22:17:57 UTC
I following comment 59, still no luck
Comment 67 Brendan Zagaeski (Xamarin Support) 2017-06-02 22:42:56 UTC
> still no luck

If you are interested in additional troubleshooting for a scenario where Comment 59 is not effective, please collect the detailed logging Fusion logging information as described in Comment 38 (steps 4 through 12) and attach that information to a _new_ bug report, and I will take a look.  Thanks in advance!
Comment 68 Marcin Wieczorek 2017-06-02 23:53:17 UTC
Just additional hint for those who still cannot apply workaround. In my case visual studio used app config from local app data:
C:\Users\{MY_USERNAME}\AppData\Local\Microsoft\VisualStudio\14.0\devenv.exe.config
I found that in that config I still had mapping from Mono.Postfix 2.0.0.0 to 4.0.0.0 and it caused, that workaround with replaced dll didn't worked. I edited config, and it started to work also for VS 2015 Enterprise. So as a final result I was able to apply workaround for both VS2015 and VS2017.

What helped me to find a solution was analysis of extended logfile created with configuration described in comment 38
Comment 69 safakoktem 2017-06-03 14:42:33 UTC
The step comment 43 with Run Visual Studio as administrator fixed for me
Comment 70 Suat Korkmaz 2017-06-05 07:15:39 UTC
I just tried the workaround with the provided .dll and I got a nice big error message. :)

https://puu.sh/wblRC.png
Comment 71 Suat Korkmaz 2017-06-05 07:22:13 UTC
False alarm. It worked after I unblock the dll.
Comment 72 Jeff Gonzales 2017-06-05 13:05:46 UTC
Unblock the DLL?  What do you mean?  Did you run IObit's Unlocker or something?
Comment 73 Jeff Gonzales 2017-06-05 13:08:07 UTC
I have had problems with the Posix DLL and not stopping on breakpoints using Visual Studio 2017 Professional from the very start.
Comment 74 Suat Korkmaz 2017-06-05 13:11:57 UTC
When you download or get a dll from elsewhere, windows blocks it so you have to unblock in order to use it. Just open the properties of the dll and you'll see a checkbox labeled "Unblock". Check it and you'll be good to go.
Comment 76 Brendan Zagaeski (Xamarin Support) 2017-06-06 22:13:55 UTC
## Verification status: not yet fixed as of the latest development builds

BAD:  XamarinVS development-branch (5d3bc7d)

The example scenario from Bug 56991 still hits the error with the installer package for this development version.

This is perhaps expected.  The .msi installer from this version installs 2 copies of Mono.Debugging.Soft.dll.  For example for VS 2015, it installs one copy into the "Xamarin\Xamarin" extension directory and one in the randomly named directory for the "Mono.Debugging.VisualStudio.Vsix" extension.  Both of those .dll files have a reference to "Mono.Posix, Version=2.0.0.0", but neither directory contains a Mono.Posix.dll file.

It looks like there is still some piece of packaging logic that needs to be updated to account for the changes between ff04dcc and 3c254b0 (based on the testing from Bug 56991, Comment 0) so that Mono.Posix.dll will be included into the installer correctly.

Thanks!
Comment 78 steveo275 2017-06-09 19:20:43 UTC
Issue still present in 26430.13.  Replacing dll with attached and unblocking does not work.  

Fix any day now would be nice...
Comment 79 Brendan Zagaeski (Xamarin Support) 2017-06-09 19:33:51 UTC
> Replacing dll with attached and unblocking does not work.

If you are interested in additional troubleshooting for a scenario where Comment 59 is not effective, please collect the detailed logging Fusion logging information as described in Comment 38 (steps 4 through 12) and attach that information to a _new_ bug report, and I will take a look.  Thanks in advance!
Comment 80 anton.duzenko@gmail.com 2017-06-12 07:44:32 UTC
Still not fixed after update to 476 on my home laptop.
Comment 81 cunnpole 2017-06-12 14:54:27 UTC
For anyone still having the problem after unblocking the posix dll: Run Sysinternals (Microsoft) Process Monitor (https://live.sysinternals.com/Procmon.exe). Add a filter for Path Contains Mono.Posix.dll. Run the VS2017 debugger. Find a result such as NAME NOT FOUND and viola! In my case it was looking in: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\wyhgzaqi.mh1

I simply dropped the Mono.Posix.dll in there too and problem solved.
Comment 82 Brendan Zagaeski (Xamarin Support) 2017-06-13 05:42:22 UTC
## Verification status update



### VS 2015: Verified for the example scenario from Bug 56991 using latest candidate build

GOOD: XamarinVS 4.5.0.486 (fec6f88) [*]
BAD:  XamarinVS 4.5.0.476 (1be4f0c)

[*] Unpublished build that is a candidate for publication in VS 2015 (and VS 2013) within the next few days, depending on the results of a few short additional tests.



### VS 2017 version 15.2 (26430.13): Fix not yet fully included in upstream Visual Studio 2017 installer manifest, waiting on follow-up Bug 57420

The candidate fix mentioned in Comment 31 corresponds to a commit in the public Mono debugger-libs repository: https://github.com/mono/debugger-libs/commit/fb757acf6accfee5f6adc033aca7ece5eb3e804c.  That commit alters Mono.Debugging.Soft.dll so that it no longer needs Mono.Posix.dll _at all_ on Windows.

But the new Mono.Debugging.Soft.dll file is currently only included in the "Xamarin.VisualStudio" extension directory.  The "Mono.Debugging" extension directory still has the _old_ version of the file.

Possible alternate temporary workaround: In my brief tests with the example scenario from Bug 56991, I was able to stop the problem by copying the new Mono.Debugging.Soft.dll file from the "Xamarin.VisualStudio" directory into the "Mono.Debugging" directory when using the latest version of Visual Studio 2017.
Comment 83 softlion 2017-06-13 06:52:56 UTC
Thks Brendan, that fixed it.
Comment 84 Fabio Pagano 2017-06-13 17:02:18 UTC
Brendan's workaround in comment 82 has worked for me too in VS2017. Thank you.
Comment 85 Fabio 2017-06-14 12:05:34 UTC
The solution suggested from Brendan doesn't work for me, but the solution suggested from Xamarin https://releases.xamarin.com/common-issues-in-the-xamarin-15-2-2-release-being-tracked-by-the-xamarin-team/ does
Comment 86 jeroen.bernsen 2017-06-15 09:41:00 UTC
Would be nice to mention that a restart of Visual Studio is needed after copying the DLL.
Comment 87 Felipe de Souza Longo 2017-06-17 23:00:33 UTC
Thanks a lot for the fix.
Downloading the Mono.Posix.DLL 2.0.0 in the attachment and installing in the GAC (gacutil) worked for me.

I had do desinstall the 4.0.0.0 version previously installed thou.

i followed this solution
https://forums.xamarin.com/discussion/96445/mono-poxis-not-foun
Comment 88 Cameron 2017-06-20 15:44:37 UTC
I followed your advice cunnpole (comment 81). Except when I ran it, I got 95 events of missing mono.posix references. I can send you a logfile from process monitor if you want.
Comment 89 ralphcgutierrez 2017-06-22 13:32:54 UTC
any update to this bug?
Comment 90 ralphcgutierrez 2017-06-22 14:05:03 UTC
Sorry I overlooked the solution:

https://releases.xamarin.com/common-issues-in-the-xamarin-15-2-2-release-being-tracked-by-the-xamarin-team/

Thanks.
Comment 93 Guillermo Zepeda 2017-07-13 23:42:00 UTC
I confirm the workaround of comments https://bugzilla.xamarin.com/show_bug.cgi?id=56787#c41. I am on VS 2017 Enterprise.
Comment 94 Brendan Zagaeski (Xamarin Support) 2017-07-21 19:08:31 UTC
*** Bug 58288 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.