关于使用PCL多次定义类型的奇怪错误



我有Xamarin。Android, Xamarin的。iOS和Windows Phone 8应用程序,都引用了通用的PCL库。在这个库中,我使用HttpClient,因为WP8,我需要nuget包Microsoft.Net.Http.2.2.22

在HttpClient上没有启用压缩,在所有3个平台上都可以正常工作。但是,在将代码更改为

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

在iOS上的库存在构建错误(Android和WP都可以正常工作),告诉我DecompressionMethods的多个定义。什么是奇怪的-在错误中提到的第二个程序集是System.Net.Primitives.dll -它不包含解压方法的定义(我甚至在ILSpy检查)。

当然,我尝试了干净的解决方案,重建,关闭/打开Xamarin Studio等…

错误:

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

编辑:关于开发环境的版本信息:

== Xamarin Studio ===

Version 4.2.4 (build 35)(…)运行时:Mono 3.2.6((no/9b58377) GTK+ 2.24.23 (Raleigh theme)

软件包版本号:302060000

=== Apple Developer Tools ===

Xcode 5.1.1 (5085) Build 5B1008

= = = Xamarin的。iOS = = =

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

= = = Xamarin的。Mac = = =

Xamarin的。Mac: Not Installed

= = = Xamarin的。Android = = =

版本:4.12.3(商业版)/用户/vtoth/图书馆/开发/Xamarin/android-sdk-mac_x86支持Android版本:2.1 (API级别7)2.2 (API级别8)2.3 (API等级10)3.1 (API等级12)4.0 (API级别14)4.0.3 (API等级15)4.3 (API等级18)4.4 (API级别19)Java SDK:/usr Java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462- 11m4609HotSpot(TM) 64位服务器VM (build 20.65-b04-462, mixed mode)

=== Build Information ===

发布ID: 402040035构建日期:2014-04-1713:45:52-04 Xamarin添加:53bde0041263928e8bd64686f5ca5a8e4338dd76

===操作系统===

Mac OS X 10.9.2

在评论中讨论后,在我看来,你正在运行一个旧版本的Xamarin Studio, Xamarin。iOS和Xamarin.Android.

请确保您至少有以下稳定版本或更新版本(目前在稳定频道上可用):

  • Xamarin Studio: 5.0
  • 莫诺:
  • 3.4.0
  • gtk#: 2.24.23
  • Xamarin的。iOS: 7.2.3.39
  • Xamarin的。Android: 4.12.4
  • XCode: 5.1.1

请尝试更新,你的问题应该会消失,加上你会得到一个更好的版本Xamarin Studio工作!

相关内容

最新更新