gpt4 book ai didi

xamarin.ios - 使用 PCL 多次定义类型的奇怪错误

转载 作者:行者123 更新时间:2023-12-01 05:12:06 28 4
gpt4 key购买 nike

我有 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 - 不包含 DecompressionMethods 的定义(我什至在 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) 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

最佳答案

在评论中讨论后,在我看来,您运行的是旧版本的 Xamarin Studio、Xamarin.iOS 和 Xamarin.Android。

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

  • 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 版本!

    关于xamarin.ios - 使用 PCL 多次定义类型的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23995999/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com