|Summary:||[XI 8.10] Enabling linker with Profile 7 PCL that uses System.IO.Compression causes "Could not load file or assembly 'System.IO.Compression'" at runtime|
|Product:||iOS||Reporter:||Brendan Zagaeski (Xamarin Support) <brendan.zagaeski>|
|Component:||General||Assignee:||Sebastien Pouliot <sebastien>|
|Severity:||normal||CC:||alberto, benjamin, christophe.faucon, cody.beyer, gouri.kumari, Ian.Ceicys, john.miller, mono-bugs+monotouch, patridge, sadika, sebastien, tom.philpot|
|Target Milestone:||8.10.4 (C5SR3)|
|Tags:||Is this bug a regression?:||---|
|Last known good build:|
Diagnostic build output
Description Brendan Zagaeski (Xamarin Support) 2015-04-17 15:21:05 UTC
Created attachment 10805 [details] Test case Enabling linker with Profile 7 PCL that uses System.IO.Compression causes "Could not load file or assembly 'System.IO.Compression'" at runtime Regression status: REGRESSION between 126.96.36.199 (f7736a4) and 188.8.131.52 (7741cc4) ## Steps to reproduce 1. Build and run the attached test case in the "Debug|iPhoneSimulator" configuration. This configuration currently has "Linker behavior" set to "Link SDK assemblies only". The test case is very simple. It contains: A. A Profile 7 PCL project with just 1 static method that uses `System.IO.Compression.GZipStream`. B. A template iOS project that references the PCL project and instantiates a class from it. ## Results ### Top of the stack trace from the "Application Output" > Could not load file or assembly 'System.IO.Compression' 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) [0x00081] in /Users/builder/data/lanes/1503/7741cc49/source/mono/mcs/class/corlib/System/AppDomain.cs:706 > at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/data/lanes/1503/7741cc49/source/mono/mcs/class/corlib/System/AppDomain.cs:674 ### The `.app` bundle does not contain "System.IO.Compression" > $ ls UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System*.dll > UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System.dll ## Workaround 1. Add "-linkskip=System.IO.Compression" under "project options -> iOS Build -> Additional mtouch arguments" ### The `.app` bundle now _does_ include "System.IO.Compression" > $ ls UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System*.dll > UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System.Core.dll > UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System.IO.Compression.dll > UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System.dll ## Results on 184.108.40.206 (f7736a4) The `.app` bundle does _not_ include "System.IO.Compression": > $ ls UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System*.dll > UnifiedSingleViewIphone1/bin/iPhoneSimulator/Debug/UnifiedSingleViewIphone1.app/System.dll But the app runs successfully, with no errors. ## Version info ### OS X 10.9.5, MacBook Air === Xamarin Studio === Version 5.9 (build 426) Installation UUID: 2c0ea975-8f73-4920-8414-3e9ae359fbf4 Runtime: Mono 4.0.0 ((detached/d136b79) GTK+ 2.24.23 (Raleigh theme) Package version: 400000143 === Apple Developer Tools === Xcode 6.1.1 (6611) Build 6A2008a === Xamarin.iOS === Version: 220.127.116.11 (Business Edition) Hash: 7741cc4 Branch: master Build date: 2015-04-13 16:37:28-0400
Comment 1 Brendan Zagaeski (Xamarin Support) 2015-04-17 15:21:36 UTC
Created attachment 10806 [details] Diagnostic build output
Comment 3 Brendan Zagaeski (Xamarin Support) 2015-04-17 15:28:44 UTC
*** Bug 29174 has been marked as a duplicate of this bug. ***
Comment 6 Sebastien Pouliot 2015-04-17 17:05:05 UTC
It looks like it's a simulator-only issue and caused by some additional sharing of code between Xamarin.iOS and Xamarin.Mac (2.0). In short the assembly is not really needed (which is why it worked in XI 8.9 and earlier) but is now being pre-loaded but (since it's missing) it cause an exception. The additional `linkskip` argument force the assembly to be present, and why it works on XI 8.10 with that workaround.
Comment 7 Sebastien Pouliot 2015-04-17 17:47:38 UTC
I committed a small workaround that can be used (and maybe backport) to confirm the issue until we identify why this is not copied (possibly normal since device builds works and don't need it). * maccore/master 0e75ff303f62256b052c54c0347456ebbe522f1d
Comment 8 Sebastien Pouliot 2015-04-18 14:03:29 UTC
What's happened is that we remove the reference for System.IO.Compression 18.104.22.168, but the PCL profiles uses 22.214.171.124. It's was not an issue since the removal of the assembly means that nothing was using it (which is often the case for facades assemblies, the original assemblies is resolved). However the extra reference still existed an d the new, pre-loading, code caused this to fail in the simulator. A fix will shortly be in mono (but will require more testing than my previous workaround).
Comment 10 Sebastien Pouliot 2015-04-21 21:36:44 UTC
Fixed in mono/master a497d8ad0cae2a9958d84e7d266122296de0aa23 Bumped in maccore/master de2fcf89c4152b8a5ffeb1be04ad38ee71709e35 ^ once verified in master we can see if we're better with this one (needs more testing) or the previous workaround/warning, safer) for the service release.
Comment 11 Alberto GH 2015-04-22 06:35:03 UTC
Just wanted to add that this issue happens with Xamarin.Mac too. Is it being fixed for both platforms or have you fixed it only for iOS?
Comment 12 Sebastien Pouliot 2015-04-23 11:12:53 UTC
@Alberto the fix was done in mono itself (i.e. not inside specific products) so the fix will be part of all new Xamarin products (including XM).
Comment 13 Alberto GH 2015-04-23 12:16:17 UTC
@Sebastien, Thanks for the confirmation.
Comment 16 Sebastien Pouliot 2015-05-14 10:19:33 UTC
*** Bug 30039 has been marked as a duplicate of this bug. ***
Comment 17 Sadik Ali 2015-05-18 09:58:16 UTC
First, I have checked this issue and able to reproduce the above behavior with the help of sample attached with the bug.When I run the attached sample on simulator it deploy successfully but gives the stack trace in Application Output. I am using the Following builds: XS: 126.96.36.199 Mono: 188.8.131.52 XI: 184.108.40.206 I have checked this issue with the master builds.Application deploy successfully on simulator without any stack trace in application output. I am using the following builds: XS: 6.0(Build 650) Mono: 220.127.116.119 XI: 18.104.22.1681 Hence I am closing this issue
Comment 19 softlion 2015-05-22 08:33:59 UTC
Same problem with a PCL profile 49 if it uses the nuget package Microsoft.Net.Http [22-mai-2015 14:30:04] Warning: The dependency 'System.Threading.Tasks, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of the assembly 'Ac.Shared, Version=126.96.36.199, Culture=neutral, PublicKeyToken=null' was not found. Please review the project's references. Xamarin.iOS 188.8.131.52
Comment 20 Sebastien Pouliot 2015-05-22 09:09:51 UTC
That's schedule for SR2, XI 8.10.2.x The above workaround can be used in the mean time.
Comment 21 Rolf Bjarne Kvinge [MSFT] 2015-05-27 09:02:35 UTC
*** Bug 30496 has been marked as a duplicate of this bug. ***
Comment 22 Ian Ceicys 2015-07-14 09:39:21 UTC
Just to close out this bug. I have verified I am able to run the attached sample and deploy to the iPhoneSimulator without any issue. Version Info: Microsoft Visual Studio Ultimate 2013 Version 12.0.31101.00 Update 4 Microsoft .NET Framework Version 4.6.00079 Xamarin 3.11.774.0 (d6c2770) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin.Android 184.108.40.206 (f6f57295eea6943c084c101f953ef699a5dc82c8) Visual Studio plugin to enable development for Xamarin.Android. Xamarin.Forms Intellisense 1.0 Provides intellisense for Xamarin.Forms in the XML editor. Xamarin.iOS 220.127.116.11 (c57a2c7d806a18cc56c1f9f3aaf91cb17b791d02) Visual Studio extension to enable development for Xamarin.iOS