4

I have Xamarin.Android, Xamarin.iOS and Windows Phone 8 applications, both referencing common PCL library. Inside this library I am using HttpClient, and because WP8, I need nuget package Microsoft.Net.Http.2.2.22

Without enabling compression on HttpClient everything works fine on all 3 platforms. However, after changing code to

var handler = new HttpClientHandler();
if (handler.SupportsAutomaticDecompression)
{
    handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
}
httpClient = new HttpClient(handler);

there is build error with the library on iOS (both Android and WP works fine with this) telling me about multiple definition of DecompressionMethods. What is strange - the second assembly mentioned in error is System.Net.Primitives.dll - which DOES NOT contain definition of DecompressionMethods (i even checked in ILSpy).

Of course, I tried clean solution, rebuild, close/open Xamarin Studio etc...

Error :

MyApiHttpClient.cs(30,50): error CS0433: The imported type  `System.Net.DecompressionMethods' is defined multiple times
/Users/vtoth/myprototype/Services/CommonServices/../../packages/Microsoft.Net.Http.2.2.22/lib/portable-net40+sl4+win8+wp71+wpa81/System.Net.Http.Primitives.dll (Location of the symbol related to previous error)
/Library/Frameworks/Mono.framework/Versions/3.2.6/lib/mono/xbuild-frameworks/.NETPortable/v4.5/Profile/Profile49/System.Net.Primitives.dll (Location of the symbol related to previous error)
Task "Csc" execution -- FAILED
Done building target "CoreCompile" in project "/Users/vtoth/myprototype/Services/CommonServices/CommonServices.csproj".-- FAILED

EDIT: Version info about dev environment:

=== Xamarin Studio ===

Version 4.2.4 (build 35) Installation UUID: (...) Runtime: Mono 3.2.6 ((no/9b58377) GTK+ 2.24.23 (Raleigh theme)

Package version: 302060000

=== Apple Developer Tools ===

Xcode 5.1.1 (5085) Build 5B1008

=== Xamarin.iOS ===

Version: 7.2.1.42 (Business Edition) Hash: 773c77c Branch: Build date: 2014-04-18 15:39:16-0400

=== Xamarin.Mac ===

Xamarin.Mac: Not Installed

=== Xamarin.Android ===

Version: 4.12.3 (Business Edition) Android SDK: /Users/vtoth/Library/Developer/Xamarin/android-sdk-mac_x86 Supported Android versions: 2.1 (API level 7) 2.2 (API level 8) 2.3 (API level 10) 3.1 (API level 12) 4.0 (API level 14) 4.0.3 (API level 15) 4.3 (API level 18) 4.4 (API level 19) Java SDK: /usr java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Build Information ===

Release ID: 402040035 Git revision: 1173cb1c45bc56cb702e82cd21a7c9d0cea4acbf Build date: 2014-04-17 13:45:52-04 Xamarin addins: 53bde0041263928e8bd64686f5ca5a8e4338dd76

=== Operating System ===

Mac OS X 10.9.2

rouen
  • 5,003
  • 2
  • 25
  • 48
  • 1
    I'm not able to reproduce this myself using the latest stable channel of Xamarin products... I've created a repro project, please see if you have issues with it yourself: https://github.com/Redth/Xamarin.HttpClient.Repro – Redth Jun 10 '14 at 11:55
  • Hi, thanks for your effort! I tried your repro project, and the error is present in it too - for both PCL projects. Any ideas? – rouen Jun 10 '14 at 14:49
  • Are you running this in Visual Studio on Windows, or Mac ? – Redth Jun 10 '14 at 14:56
  • Xamarin Studio on Mac, i edited my question with detailed info – rouen Jun 10 '14 at 15:02
  • Hmm, me too (Xamarin Studio on the Mac)... What are your versions of all the products installed? Go to Xamarin Studio -> About Xamarin Studio -> Show Details and then copy that info... – Redth Jun 10 '14 at 15:54
  • see my question again - i added xamarin studio details – rouen Jun 10 '14 at 15:58

1 Answers1

1

After discussing in the comments, it seems to me that you are running an old version of Xamarin Studio, Xamarin.iOS, and Xamarin.Android.

Please make sure you have at least the following stable versions or newer (which are available on the stable channel currently:

  • Xamarin Studio: 5.0
  • Mono: 3.4.0
  • GTK#: 2.24.23
  • Xamarin.iOS: 7.2.3.39
  • Xamarin.Android: 4.12.4
  • XCode: 5.1.1

Please try updating and your problems should go away, plus you'll get a much nicer version of Xamarin Studio to work with!

Redth
  • 5,464
  • 6
  • 34
  • 54
  • well, since we are before release, this is the worst time to upgrade environment and possibly find new problems, so I cant verify if this resolves the issue. However, since I must award the bounty now or let it fall, I will award to you for your effort with repro project :) and will you know later if upgrade helped. Thanks – rouen Jun 12 '14 at 12:29