Reputation: 21098
Starting a new Portable Class Library project, I've added the Flurl.Http NuGet package, which appears to have also brought down all it's dependancies, as expected.
However when I add the using Flurl.Http directive and some simple code such as
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
public class ClientRepository
{
public async Task<string> Connect()
{
var result = await "http://example.com"
.AppendPathSegment("/login")
.PostUrlEncodedAsync(new { username = "you", password = "password" }).ReceiveJson();
return result.token;
}
}
I get the compile error
The type or namespace name 'Http' does not exist in the namespace 'Flurl' (are you missing an assembly reference?)
What's odd that intellisense has no problem recognizing the .Http namespace, or the extension methods (PostUrlEncodedAsync)
What could I be missing from this most basic of PCL projects?
Perhaps my package.config file would be of value, so here it is as well:
<packages>
<package id="Flurl" version="1.0.5" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
<package id="Flurl.Http" version="0.4.1" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
<package id="PCLStorage" version="0.9.6" targetFramework="portable-net45+sl50+MonoAndroid10+xamarinios10+MonoTouch10" />
</packages>
Upvotes: 0
Views: 1478
Reputation: 39319
I was able to reproduce using the combination of target platforms gleaned from your packages.config (very helpful). The problem appears to be with Silverlight 5. This was working at one point; my hunch is that support was dropped for it in one of the dependent libraries, though I've not yet confirmed that.
At any rate, if you can get by without SL5 support (and maybe you can't), I've confirmed that a new PCL targeting all the others that Flurl.Http is documented to support does build with your code:
(Side note: I've run into issues trying to change PCL targets in existing projects - you might save yourself some headaches by starting with a clean slate.)
My apologies for any inconvenience. I'll update the list of supported targets in the docs. I welcome any suggestions/pull requests to get it working with SL5.
Upvotes: 1