简体   繁体   English

.NET Core中缺少方法异常

[英]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: 因此,我尝试使用在这里找到的扩展方法来检查TCP连接是否仍处于活动状态,但是我遇到了一个缺少的方法异常:

"Method not found: 'System.Net.IPEndPoint System.Net.NetworkInformation.TcpConnectionInformation.get_LocalEndPoint()'" “找不到方法:'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: 我认为在引用NetworkInformation时可能存在问题的JSON文件:

{
  "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. 也尝试添加system.net.security软件包,因为system.net.networkinformation取决于安全软件包。 It might not have loaded dependencies automatically. 它可能没有自动加载依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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