-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working with Portable Class Library #100
Comments
Hello there, That websocket-sharp library is built with .NET Framework 3.5 as target framework. And if the Portable Class Library supports only .NET Framework 4.0 or higher, i guess you cannot use it in your Portable Class Library project. So, if you would like to use websocket-sharp in your project, i guess you should build it with your target framework (4.0 or higher) by yourself. |
Hi! Thanks for your feedback. I ended up using a shared project with a wrapper around your websocket-sharp library. So I can use it in my cross platform projects, while my code still based in a portable class library. |
@speier-- I know this is a closed issue, but would you mind giving a brief example if you get a chance? I think I'm running into the same issue |
@speier @wardcraigj I have the same issue here, any link to the websocket-sharp wrapper? |
@hopewise, I've been a bit consumed by another project, but I got a reply on another thread about a different websocket library that will work with UWP #270 (comment) I haven't tested it though |
@sta I tried to re-build your library by targeting mono / .NET 4.5, it has successfully got compiled, however when I try to add the resulted dll file to my xamarin project, I got:
Any advice about building your library and use it in my xamarin project? @wardcraigj do you have an idea about what I am missing? I still need to use this library as it has most of what I need.. |
I'm not entirely sure. If FileInfo is the only reference to mscorlib in the library, it might be easy enough to refactor it so its not needed? I wish I could be more helpful but I really haven't poked around in the library very much so I'm not sure where or why FileInfo is used. If you do manage to compile a modified version of the library, that would be very handy! |
Thanks, I have finally solved the issue, simply by commenting all methods that uses FileInfo, as I am not sending files content through the socket, but only straight strings.. |
I've implemented a workaround for Xamarin.Forms via the dependency service approach: using System;
using System.Threading.Tasks;
using WebSocketSharp;
using MyProject.Shared;
[assembly: Xamarin.Forms.Dependency (typeof (WebSocketSender))]
namespace MyProject.Shared
{
public class WebSocketSender : IWebSocketSender
{
/// <summary>
/// Empty method for reference.
/// </summary>
public static void Init ()
{
}
/// <summary>
/// Sends the message through the specified WebSocket connection.
/// </summary>
public Task<bool> SendMessage (WebSocket connection, string message)
{
var t = new TaskCompletionSource<bool> ();
connection.SendAsync (
(string)message,
(result) => t.TrySetResult (result));
return t.Task;
}
}
} |
I forked this project and remove unnecessary Send(FileInfo) method for Xamarin PCL project. |
I'm trying to use your library in a Portable Class Library (Profile7) with Xamarin Studio, get the latest pre-release version
1.0.3-rc6
via Nuget, it seems installed correctly.But when I try to call the
Send
method, I got the following error:Reference to type 'System.IO.FileInfo' claims it is defined assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found
Is that possible to use your library in a Portable Class Library?
Could you please help with this problem, many thanks!
The text was updated successfully, but these errors were encountered: