Search code examples
c#portable-class-library

Setting an alias on the .net Portable Subset library


I'm using the nuget package Microsoft.Net.Http to add HttpClient to my PCL Domain Library.

I want to set a custom network credential, but I can't because of this error:

Code :

HttpClientHandler handler = new HttpClientHandler();
ICredentials credentials = new NetworkCredential("username", "password", "domain");
handler.Credentials = credentials;
_client = new HttpClient(handler);

Error :

Error 5 Cannot implicitly convert type 'System.Net.ICredentials [c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile78\System.Net.Primitives.dll]' to 'System.Net.ICredentials' C:[truncated]\ApiClient.cs 26 35 DeltekApi

The issue is that the networkcredentials I'm providing implement the nuget added implementation of ICredentials, and the interface HttpClient wants is the PCL .Net Portable Subset version.

Can't really think of a good way of fixing this?


Solution

  • This sounds like a bug we had if you install VS 2012 Update 2 after the WP8 SDK. Run a repair on the VS Update 2 installation to fix it. See Issue 2 in this KB article for more information.