WebSocket4Net icon indicating copy to clipboard operation
WebSocket4Net copied to clipboard

Converting a project to PCL that depends on WebSocket4Net

Open ikbenben opened this issue 8 years ago • 4 comments

Hi there

I'm trying to convert the Pusher dotnet library, https://github.com/pusher-community/pusher-websocket-dotnet , to be PCL so that it can be used in a Xamarin project however I'm having trouble adding WebSocket4Net to the Pusher PCL library.

I get the following error

Could not install package 'WebSocket4Net 0.14.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I know I need to have the Profile and Target frameworks match with WebSocket4Net and I'm good with keeping the same level of support but I'm not sure where to find that information in your repository. There are a number of different solution and project files so I'm a bit confused

Can you tell me which settings you are using so I can match them

thanks

ikbenben avatar Dec 14 '16 00:12 ikbenben

As far as I know, Websockts4Net uses the NETStandard.Library 1.6.1, netstarndard1.6 based PCL as opposed to a profile based PCL.

Have you converted Pusher to NETStandard based PCL yet? If so, reply with a snippet of your project.json file. I had a similar issue and my error was in the Frameworks section of the project.json file.... I was missing the imports section.

I'm not at work now so I can't demonstrate what it should look like. Let me know

gcadmes avatar Dec 22 '16 05:12 gcadmes

Thanks. I'm on Mac and don't seem to have netstandard1.6 available in the options dialog. I only have netstandard1.5. Any ideas how to get 1.6? Is there a reason you are not targeting a lower netstandard? Maybe that was your issue in the Framworks section?

{
  "dependencies": {
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "1.6.1"
  },
  "frameworks": {
    "netstandard1.5": {}
  }
}

ikbenben avatar Dec 22 '16 10:12 ikbenben

Hi @gcadmes , do you have any feedback? thanks

ikbenben avatar Jan 04 '17 16:01 ikbenben

My apologies for not getting back to you sooner. I was out over the holidays and just getting back...

Here is a snippet of my project.json file:

{
  "supports": {},
  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.2-beta1",
    "WebSocket4Net": "0.15.0-beta6",
    "Websockets.Pcl": "1.1.9",
    "modernhttpclient": "2.4.2"

  },
  "frameworks": {
    "netstandard1.4": {
      "imports": "portable-net45+win8+wpa81+wp8"
    }
  }
}

Firstly, the reason I've referenced three different Websocket libraries is due to my research efforts in choosing a websocket library to wrap. Unfortunately, WebSocket4Net and WebSocketsPCL have TLS issues on Android, and WebSocketsPCL doesn't support SSL on iOS either.

Also, if you're using Xamarin.Forms, referencing ""Microsoft.NETCore.Portable.Compatibility": "1.0.1"" does not seem to work. This link helps explain that in more detail: https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/

If you want to support UWP, then you'll have to change your 'netstandard1.5' to 'netstandard1.4'. In case you haven't see this blog, it explains netstandard, much better than can. https://blogs.msdn.microsoft.com/microsoft_press/2016/07/26/from-the-mvps-key-steps-in-developing-net-core-applications/

I hope this helps, let me know. I'll get back sooner next time now that I'm back in the office.

gcadmes avatar Jan 05 '17 14:01 gcadmes