# Error while using HttpClient’s AutomaticDecompression in Portable Libraries

- Link: https://saguiitay.com/error-while-using-httpclients-automaticdecompression-in-portable-libraries/
- Published: 2013-08-23T12:45:00+03:00
- Author: Itay

Adding automatic decompression support to an [HttpClient](https://learn.microsoft.com/en-us/previous-versions/visualstudio/hh193681(v=vs.118))
is quite easy:

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

This works even in Portable Libraries. However, if you try to call this from a different
project, you might encounter the strange exception below:

> Method not found: `void System.Net.Http.HttpClientHandler.set_AutomaticDecompression(
> System.Net.DecompressionMethods)`.

This doesn’t give too much information – for some reason, the setter of the `AutomaticDecompression`
property was not found, which prevents the code from JIT’ing. Apparently, the solution
for that is quite simple – you need to make sure that the project that calls the
Portable Library also refers to the [Microsoft.Net.Http Nuget package](https://www.nuget.org/packages/Microsoft.Net.Http/).

### _Related_
