【问题标题】:HttpClient + gzip at PCL causes method not found: 'System.Net.Http.HttpClientHandler.ser_AutomaticDecompression'PCL 处的 HttpClient + gzip 导致找不到方法:'System.Net.Http.HttpClientHandler.ser_AutomaticDecompression'
【发布时间】:2014-11-09 12:49:42
【问题描述】:

我正在向 HttpClient 驻留在可移植类库 (Profile49) 中的 Xamarin.Android 应用程序添加 gzip 压缩支持。

每次我尝试调用 HttpClient 时都会收到以下错误:

找不到方法: 'System.Net.Http.HttpClientHandler.ser_AutomaticDecompression

代码如下:

 var handler = new HttpClientHandler();
 handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
 using (var client = new HttpClient(handler))
 ...

【问题讨论】:

  • 您使用的是什么版本的 xamarin?工作室也一样?
  • alpha 通道的最新消息:1. Xamarin.Android (VS Plugin) 4.16.0.14 | 2. Xamarin.Studio 5.4(内部版本 236)| 3. Visual Studio 2013 更新 3 | 4. API 级别 19+
  • 您能否使用稳定版本重现该问题?又名非阿尔法?
  • @AlexeyStrakh 你解决了这个问题吗?我面临着完全相同的问题。

标签: xamarin xamarin.android gzip httpclient portable-class-library


【解决方案1】:

如果我没记错的话,您需要在使用 PCL 的项目中添加对 httpclient 包的引用。PCL 中的引用是不够的,您的其他项目需要引用 httpclient BCL nuget 包也是如此。

【讨论】:

  • 将“Microsoft.Bcl.Build 1.0.14”添加到 CFSA.Android。安装失败。回滚...无法安装包“Microsoft.Bcl.Build 1.0.14”。您正在尝试将此包安装到以“MonoAndroid,Version=v4.4”为目标的项目中,但该包不包含任何与该框架兼容的程序集引用或内容文件。更多信息,请联系包作者dropbox.com/s/jj95xh44tb1ksja/shot_140916_143132.png?dl=0
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-02
  • 2023-04-05
  • 2019-06-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多