简体   繁体   中英

Missing method exception in .net core

I think this may have something to do with the dependencies, but I'm not really sure.

So I'm trying to check to see if a TCP connection is still active using the extension method I found here , but I'm getting a missing method exception:

"Method not found: 'System.Net.IPEndPoint System.Net.NetworkInformation.TcpConnectionInformation.get_LocalEndPoint()'"

Which I'm a little confused on since the method seems to exist .

Here's the code:

 public static TcpState GetState(this TcpClient tcpClient)
        {

                var status = IPGlobalProperties.GetIPGlobalProperties()
                                               .GetActiveTcpConnections()
                                               .SingleOrDefault(x => x.LocalEndPoint.Equals(tcpClient.Client.LocalEndPoint));

                return status != null ? status.State : TcpState.Unknown;

        }

and the JSON file where I think there might be a problem in how NetworkInformation is referenced:

{
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      },
      "imports": "dnxcore50"
    }
  },
  "dependencies": {
    "system.net.networkinformation": "4.0.10-beta-23123"

  },
  "version": "1.0.0-*"
}

Am I on the right track? How would I fix it?

Try adding system.net.security package also, as system.net.networkinformation depends on security package. It might not have loaded dependencies automatically.

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