Runtime binding bug with .NET Standard Socket in a .NET Desktop console app


I got a very simple test I am writing to do a client server communication sample in .NET Standard (1.4).
At runtime I got a type load exception as follows:

System.IO.FileNotFoundException: ‘Could not load file or assembly ‘System.Net.Sockets, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.’

My .NET Standard server class

public class NetworkServerEcho
    public async void Start(int port)
        var server = new TcpListener(new IPEndPoint(IPAddress.Any, port));
        while (true)
            var connection = await server.AcceptSocketAsync();
            var t = Task.Run(() => HandleConnection(connection));
    private async void HandleConnection(Socket connection)
        // ..

Nuget dependency: System.Net.Sockets (4.3.0)

.NET Framework (4.6) / console test app

class Program
    static void Main(string[] args)
        int port = 5434;
        var p = new HelloEcho();
        var ser = new NetworkServerEcho(p);

What am I missing?

There is no System.Net.Sockets in the .NET Framework. I was expecting some binding redirect magic that would solve the problem. The .NET Standard System.Net.Sockets package declare it supports .NET Framework 4.6. Sockets are in System.dll on the desktop.


Never mind, solved it, had to add those dependency in the .NET Framework app as well…
Makes perfect sense but I was confused for a while… All good now!


I am having same problem.
How did you solve it. Please give the details

.NET Foundation Website | Blog | Projects | Code of Conduct