Bug 31560

Summary: [XI 8.10] Enabling linker for PCL with "duplicate" System.Threading.Tasks references causes "Could not load file or assembly 'System.Threading.Tasks'" on simulator
Product: iOS Reporter: Brendan Zagaeski (Xamarin Team, assistant) <brendan.zagaeski>
Component: GeneralAssignee: Bugzilla <bugzilla>
Status: VERIFIED FIXED    
Severity: minor CC: gouri.kumari, mono-bugs+monotouch, pj.beaman, sebastien, wessel.kroos
Priority: Low    
Version: XI 8.10   
Target Milestone: 9.2 (C6)   
Hardware: PC   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:
Bug Depends on: 31379    
Bug Blocks:    
Attachments: Test case

Description Brendan Zagaeski (Xamarin Team, assistant) 2015-07-01 21:09:17 UTC
Created attachment 11813 [details]
Test case

[XI 8.10] Enabling linker for PCL with "duplicate" System.Threading.Tasks references causes "Could not load file or assembly 'System.Threading.Tasks'" on simulator

This is almost certainly a duplicate of Bug 31379, but I will file it anyway because the test case is simple, so it might be useful for QA to verify that this test case is also fixed after Bug 31379 is fixed.




## Workarounds

As with Bug 31379 and Bug 29211, there are at least 2 workarounds:

1. Disable the linker for simulator builds. This both stops the problem and makes the build time significantly faster.

2. Add "-linkskip=System.Threading.Tasks" under "project options -> iOS Build -> Additional mtouch arguments".




## Steps to reproduce

Build and run the attached test case in the "Debug|iPhoneSimulator"
configuration.




## Results 

The app crashes due to a missing "System.Threading.Tasks" dependency.



### Excerpt from the simulator console log
> 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) [0x00081] in /Users/builder/data/lanes/1880/ef8c2f77/source/mono/mcs/class/corlib/System/AppDomain.cs:706 



### Related build warning from the diagnostic build output

> There was a conflict between "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and
> "System.Threading.Tasks, Version=1.5.11.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".



### Assemblies referenced by the Windows-compiled `HttpAsyncLibrary.dll`

> $ monop -r:HttpAsyncTest/libs/HttpAsyncLibrary.dll --refs
> System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> System.Resources.ResourceManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> System.Diagnostics.Debug, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


Note the duplicate reference to "System.Threading.Tasks".




## Regression status: regression between XI 8.9 and XI 8.10

BAD:  Xamarin.iOS 8.10.2.37  (ef8c2f7)
GOOD: Xamarin.iOS 8.9.1.3    (f7736a4)
Comment 3 Sebastien Pouliot 2015-09-03 14:44:49 UTC
Updating milestone (the C6 release will be 9.2).
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2015-09-23 17:42:12 UTC
I am happy with calling this resolved on Xamarin.iOS 9.0 and Xamarin.iOS 9.2. In both versions the app now runs successfully on simulator. I will leave the target milestone unchanged for now. QA, if you like feel free to set the target milestone back to 9.0 after verifying on both versions.


The Application Output still shows a diagnostic error message:

> Could not find `System.Threading.Tasks` referenced by assembly `HttpAsyncLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`.


But I think that's fine because the app does run successfully on the simulator.
Comment 5 GouriKumari 2015-11-16 14:09:24 UTC
Verified with cycle6 builds and app launched successfully on simulator without any crash but diagnostic message as mentioned on comment#4 does appear. Based on comment #4 and based on my verification, I am closing this bug. 

Logs:
Application Output: https://gist.github.com/GouriKumari/052d1255dc8c42dfb68a
Test Env: https://gist.github.com/GouriKumari/264d2dbc7d4ed16b487c