简体   繁体   中英

implementing rda.SocketsForPCL Xamarin forms PCL

I need to create a tcp connection to the wireless router connected to the device, and then pass a buffer of data. That said, I installed the plugin from NuGet, Socket.Plugin , but this generates me error:

The empty PCL implementation for Sockets was loaded. Ensure you have added the Sockets nuget package to each of your platform projects.

implementation in the xamarin forms pcl project: 在此输入图像描述

call method:

  var address = "192.168.222.1";
  var port = 5555;
  var r = new Random();

    try
    {
       var client = new Sockets.Plugin.TcpSocketClient();
       await client.ConnectAsync(address, port);
    }
    catch(Exception ex)
    {
        throw ex;
    }

在此输入图像描述

When i launch the app on device, i have this error:

The empty PCL implementation for Sockets was loaded. Ensure you have added the Sockets nuget package to each of your platform projects.

Why do I get that error? everything is connected and everything is connected. How can I fix? I forgot something?

I don't know what conclusion the OP came to, but I was having this same issue. I was using the NuGet package "rda.SocketsForPCL" in a portable project.

I was referencing the portable project in a Windows application project. When trying to create a TcpSocketClient in the portable project, it would throw an exception. Turns out that the NuGet package not being referenced in the Windows application was causing this exception.

So, adding the NuGet reference to the Windows application project solved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM