繁体   English   中英

.NET Core中缺少方法异常

[英]Missing method exception in .net core

我认为这可能与依赖关系有关,但我不确定。

因此,我尝试使用在这里找到的扩展方法来检查TCP连接是否仍处于活动状态,但是我遇到了一个缺少的方法异常:

“找不到方法:'System.Net.IPEndPoint System.Net.NetworkInformation.TcpConnectionInformation.get_LocalEndPoint()'”

由于该方法似乎存在,对此我有些困惑。

这是代码:

 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;

        }

我认为在引用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-*"
}

我在正确的轨道上吗? 我该如何解决?

也尝试添加system.net.security软件包,因为system.net.networkinformation取决于安全软件包。 它可能没有自动加载依赖项。

暂无
暂无

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

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