.net core 中缺少方法异常
Missing method exception in .net core
我认为这可能与依赖关系有关,但我不太确定。
因此,我尝试使用我发现的扩展方法 here 来检查 TCP 连接是否仍处于活动状态,但我遇到了缺少方法的异常:
"Method not found: 'System.Net.IPEndPoint System.Net.NetworkInformation.TcpConnectionInformation.get_LocalEndPoint()'"
自方法 seems to exist 以来,我对此有点困惑。
代码如下:
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;
}
和 JSON 文件,我认为其中 NetworkInformation 的引用方式可能存在问题:
{
"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
取决于安全包。它可能没有自动加载依赖项。
我认为这可能与依赖关系有关,但我不太确定。
因此,我尝试使用我发现的扩展方法 here 来检查 TCP 连接是否仍处于活动状态,但我遇到了缺少方法的异常:
"Method not found: 'System.Net.IPEndPoint System.Net.NetworkInformation.TcpConnectionInformation.get_LocalEndPoint()'"
自方法 seems to exist 以来,我对此有点困惑。
代码如下:
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;
}
和 JSON 文件,我认为其中 NetworkInformation 的引用方式可能存在问题:
{
"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
取决于安全包。它可能没有自动加载依赖项。