Bug 30039

Summary: System.IO.FileNotFoundException loading assemblies on simulator
Product: iOS Reporter: Adam Patridge <patridge>
Component: GeneralAssignee: Bugzilla <bugzilla>
Status: RESOLVED DUPLICATE    
Severity: normal CC: mono-bugs+monodevelop, mono-bugs+monotouch, sebastien
Priority: ---    
Version: XI 8.10   
Target Milestone: Untriaged   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: About Xamarin Studio info

Description Adam Patridge 2015-05-13 14:05:15 UTC
Created attachment 11186 [details]
About Xamarin Studio info

After updating to v5.9.0 (and then on 5.9.1 and now into 5.9.2), I have a large app that crashes when launching on the iOS Simulator. It shows the splash screen and then crashes with a `FileNotFoundException`.

> System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks' or one of its dependencies. The system cannot find the file specified.

This issue doesn't happen on all apps. The issue did not occur with Xamarin Studio v5.8 and does not occur with v5.9.* when debugging on physical devices.

Stack trace from log:

> May 13 11:48:43 cysweb5d57 assertiond[24393]: assertion failed: 14D136 12F69: assertiond + 12334 [8E465C14-E4AE-36E9-AFBE-D28459602962]: 0x1
> May 13 11:48:43 cysweb5d57 SomeAppiOS[24556]: MonoTouch: Socket error while connecting to MonoDevelop on 127.0.0.1:10000: Connection refused
>     May 13 11:48:43 cysweb5d57 SomeAppiOS[24556]: WARNING: The runtime version supported by this application is unavailable.
>     May 13 11:48:43 cysweb5d57 SomeAppiOS[24556]: Using default runtime: v4.0.30319
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: 
>     Unhandled Exception:
>     System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks' or one of its dependencies. The system cannot find the file specified.
>     File name: 'System.Threading.Tasks'
>     at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x001e8] in /Users/builder/data/lanes/1503/f5f5a491/source/mono/mcs/class/corlib/System/AppDomain.cs:737 
>     at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/mono/mcs/class/corlib/System/AppDomain.cs:674 
>     at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:551 
>     at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1 assemblies, System.Reflection.Assembly assembly) [0x00019] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:218 
>     at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1 assemblies, System.Reflection.Assembly assembly) [0x0002c] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:220 
>     at ObjCRuntime.Runtime.RegisterEntryAssembly (System.Reflection.Assembly entry_assembly) [0x0001b] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:200 
>     at ObjCRuntime.Runtime.RegisterEntryAssembly (IntPtr a) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:158 
>     at ObjCRuntime.Runtime.register_entry_assembly (IntPtr assembly) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/runtime/Delegates.generated.cs:118 
>     at (wrapper native-to-managed) ObjCRuntime.Runtime:register_entry_assembly (intptr)
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: Unhandled managed exception:
>     Could not load file or assembly 'System.Threading.Tasks' or one of its dependencies. The system cannot find the file specified. (System.IO.FileNotFoundException)
>     at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x001e8] in /Users/builder/data/lanes/1503/f5f5a491/source/mono/mcs/class/corlib/System/AppDomain.cs:737 
>     at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/mono/mcs/class/corlib/System/AppDomain.cs:674 
>     at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:551 
>     at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1 assemblies, System.Reflection.Assembly assembly) [0x00019] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:218 
>     at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1 assemblies, System.Reflection.Assembly assembly) [0x0002c] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:220 
>     at ObjCRuntime.Runtime.RegisterEntryAssembly (System.Reflection.Assembly entry_assembly) [0x0001b] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:200 
>     at ObjCRuntime.Runtime.RegisterEntryAssembly (IntPtr a) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/src/ObjCRuntime/Runtime.cs:158 
>     at ObjCRuntime.Runtime.register_entry_assembly (IntPtr assembly) [0x00000] in /Users/builder/data/lanes/1503/f5f5a491/source/maccore/runtime/Delegates.generated.cs:118 
>     at (wrapper native-to-managed) ObjCRuntime.Runtime:register_entry_assembly (intptr)
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical: Stacktrace:
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical: 
>     Native stacktrace:
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     0   SomeAppiOS                0x001d5a17 mono_handle_native_sigsegv + 311
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     1   SomeAppiOS                0x001dc1b1 sigabrt_signal_handler + 129
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     2   libsystem_platform.dylib            0x0413403b _sigtramp + 43
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     3   ???                                 0xffffffff 0x0 + 4294967295
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     4   libsystem_sim_c.dylib               0x03ecba5a abort + 156
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     5   SomeAppiOS                0x00357c96 xamarin_unhandled_exception_handler + 342
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     6   SomeAppiOS                0x001d626b mono_invoke_unhandled_exception_hook + 91
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     7   SomeAppiOS                0x001d5118 mono_handle_exception_internal + 6200
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     8   SomeAppiOS                0x001d38d9 mono_handle_exception + 41
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     9   SomeAppiOS                0x0016cb78 mono_x86_throw_exception + 136
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     10  ???                                 0x11393f57 0x0 + 288964439
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     11  ???                                 0x11f7ec10 0x0 + 301460496
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     12  ???                                 0x11f7eb28 0x0 + 301460264
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     13  ???                                 0x11f7eaac 0x0 + 301460140
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     14  ???                                 0x11f7ead8 0x0 + 301460184
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     15  ???                                 0x11f7e9cc 0x0 + 301459916
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     16  ???                                 0x11f7e8f8 0x0 + 301459704
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     17  ???                                 0x11f7e8ac 0x0 + 301459628
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     18  ???                                 0x113e0978 0x0 + 289278328
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     19  SomeAppiOS                0x00356970 xamarin_register_entry_assembly + 32
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     20  SomeAppiOS                0x00355afd xamarin_main + 2349
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     21  SomeAppiOS                0x000ad171 main + 113
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     22  libdyld.dylib                       0x03e27ac9 start + 1
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical:     23  ???                                 0x00000001 0x0 + 1
>     May 13 11:48:44 cysweb5d57 SomeAppiOS[24556]: critical: 
>     =================================================================
>     Got a SIGABRT while executing native code. This usually indicates
>         a fatal error in the mono runtime or one of the native libraries 
>         used by your application.
>         =================================================================
>         May 13 11:48:46 cysweb5d57 com.apple.CoreSimulator.SimDevice.A645CB44-871A-4592-87C8-1D725BA28AAA.launchd_sim[24375] (UIKitApplication:com.someone.ios.someapp[0x317b][24556]): Service exited due to signal: Abort trap: 6
>         May 13 11:48:46 cysweb5d57 SpringBoard[24389]: Application 'UIKitApplication:com.someone.ios.someapp[0x317b]' crashed.
Comment 1 Jeffrey Stedfast 2015-05-13 14:11:44 UTC
If it is the app that is crashing, then it's a Xamarin.iOS bug and not a Xamarin Studio bug.
Comment 2 Sebastien Pouliot 2015-05-13 16:36:32 UTC
@Adam I'm fairly sure it's something already fixed but I need some extra information (it could also be a different cause ended at the same error). Can you share the project ?

If not can you do a Rebuild (with `-v -v -v -v`) and give me the Build Log ? 

That should give me enough information to see if it's the same condition or not. Thanks!
Comment 4 Adam Patridge 2015-05-13 17:01:20 UTC
I attached a build log (as private, for anyone else stumbling through here), but let me know if I messed something up. I put the arguments in the mtouch args and grabbed the log from the right-hand side of Errors pad.
Comment 5 Sebastien Pouliot 2015-05-13 19:45:03 UTC
> --linksdkonly

@Adam is there any reason why your simulator builds to use the linker ?

The default (for simulator) is "Don't link" because it means faster builds (but that's not true for device builds, mostly because AOT takes even more time).

In this case (if it's like the previous bug report) it should work correctly if you switch it back to the default "Don't link". Can you give this a try ?
Comment 6 Adam Patridge 2015-05-14 10:05:28 UTC
Good catch. I think we turned it on a while back to work around a different bug we encountered. This does seem to provide a workaround to allow debug builds to run just fine. Thank you for that, as it saves quite a bit of time over the physical deployments (even without the speed increase of not linking anymore).

Will linking be usable to simulator builds after the other bug is fixed? It's not critical by any means; I'm just curious.
Comment 7 Sebastien Pouliot 2015-05-14 10:19:33 UTC
Great! I'm glad that helped :-)

> Will linking be usable to simulator builds after the other bug is fixed?

Definitively! Even if it's rarely required (in real life) for the simulator it makes testing the linker a LOT easier for us :-)

The fix for this should be in 8.10.2 (or the next service release after 8.10.1).

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