.Net 2.0 Framework和GetActiveTcpConnections()错误 [英] .Net 2.0 Framework and GetActiveTcpConnections() Error

查看:122
本文介绍了.Net 2.0 Framework和GetActiveTcpConnections()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个用.Net 2.0编写的TCP主机应用程序。我们最近开始部署应用程序,并且几乎在其安装的每个站点上都遇到了相同的错误。我已经将错误跟踪到调用GetActiveTcpConnections的代码行。



Dim 属性 As NetworkInformation.IPGlobalProperties


Dim connections As NetworkInformation.TcpConnectionInformation()


properties = NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()


connections = properties.GetActiveTcpConnections()




当应用程序启动时,我扫描端口以检查一些端口信息。返回的错误是"异常:指定的参数超出了有效值的范围。参数名称:port。"我有一些测试应用程序也可以进行此调用,他们也会收到相同的错误。



正如我所提到的,几乎所有的生产安装都遇到了这个错误。奇怪的是,他们在安装后立即开始使用我的应用程序时会收到此错误,但几天之后他们会再次尝试,不再会收到错误。



这些安装主要在虚拟化的Windows 2003 Server上进行。如果没有那么他们就在非虚拟化版本上。有些有多个NIC卡,有些只有一个NIC卡。这些是32位版本。运行该程序的用户通过VM ware或远程桌面朗读服务器。



我是试图在内部复制此错误,但未能。我安装了一个干净的服务器2003 SP2安装程序,也安装在虚拟化的Windows Server 2003上。我已经安装了多个NIC卡,并且还禁用了一些以尝试获取此错误。我仍然无法在内部产生此错误,以便我可以纠正它。



任何帮助或建议都会受到很大的影响。

解决方案

这个小伙子说错误的网卡是问题 http://forums.microsoft .com / MSDN / ShowPost.aspx?PostID = 1676404& SiteID = 1 ,但在另一个帖子中另一个小伙子说不是解决方案 http://forums.microsoft.com /MSDN/ShowPost.aspx?PostID=1762482&SiteID=1 我发现很难相信第1层或第2层问题可能会在第4层造成这样的错误。


< p align = left>



.NET读取的C结构将端口号存储在32位字段中,并且当然IPEndPoint只接受(无符号)16位值(0 t) o 0xFFFF,存储在int中。我想知道是否存在一些bug / corner情况,其中本机结构的值位于u32(DWORD)的上半部分?这会导致这个问题。



在故障发生时连接调试器会很有趣,或netstat同时运行,看它是否显示任何奇怪的值。例如,我想知道当'连接'处于某种奇怪的状态时,端口号被设置为例如-1。或者也许内存在没有被清除的情况下被重用,并且内核只将16位值写入字段,因此在上半部分设置的位保持设置。 (也许netstat会隐藏这些奇怪的东西,并且需要一个简单的命令行工具来转储原始的MIB_TCPROW值。)




我将问题记录在https://connect.microsoft.com/VisualStudio反正的。理想情况下,你将包括整个例外,包括堆栈跟踪,如果你能找到坏的原生值也会很棒。


 

I have a TCP host application written in .Net 2.0.  We've recently started deploying the appication and have had the same error encountered on almost every site its been installed at.  I've traced the error to the line of code that calls GetActiveTcpConnections.

 

Dim properties As NetworkInformation.IPGlobalProperties

Dim connections As NetworkInformation.TcpConnectionInformation()

properties = NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()

connections = properties.GetActiveTcpConnections()

 

 

When the application starts up I scan through the ports to check some port information.  The error that gets returned in is "Exception: Specified argument was out of the range of valid values.  Parameter name: port."  I have some test apps that make this call as well and they also receive the same error. 

 

As I mentioned this error is encountered on almost all of the production installs.  What's strange is that they'll receive this error when they start using my application right after the install, but then a couple days later they'll try again and no longer will get the error. 

 

These installs are primarily on virtualized Windows 2003 Servers; and if not then they on the non-virtualized edition. Some have multiple NIC cards, some only have one NIC card.  These are the 32-bit editions. The user running the program is accessing the server rumotely, either through VM ware or remote desktop.

 

I've tried to duplicate this error in-house and haven't been able to.  I installed on a clean install of server 2003 SP2 and also on a virtualized windows server 2003. I've installed multiple NIC cards and also disabled some to try to get this error.  I still have not been able to produce this error in house so that I can correct it.

 

Any help or suggestions would be greatly appreaciated.

解决方案

This chap said a faulty NIC was the problem http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1676404&SiteID=1, but in another thread another chap said that wan't the solution http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1762482&SiteID=1  I find it hard to believe that a layer 1 or layer 2 problem could cause such a fault at layer 4.

 

 

The C struct that .NET reads from stores the port numbers in an 32-bit field, and of course correctly IPEndPoint will only accept an (unsigned) 16-bit value (0 to 0xFFFF, stored in an int).  I wonder if there's some bug/corner case where the native struct has a value with bits set in the top half of the u32 (DWORD)?  That would cause this problem.

 

It would be interesting to either get a debugger attached at the time the fault occurs, or netstat run at the same time to see if it shows any wierd values.  I wonder for instance if when a 'connection' is in some odd state that the port number is set to e.g. -1.  Or maybe memory is being reused without being cleared and the kernel only writes a 16-bit value to the field so then bits set in the top half remain set.  (Maybe netstat would hide such oddities and a simple command-line tool to dump the raw MIB_TCPROW values would be needed).

 

 

I'd log the issue at https://connect.microsoft.com/VisualStudio anyway.  Ideally you'd include the whole exception including stack-trace, and it would be great if you could find what the bad native values are too.


这篇关于.Net 2.0 Framework和GetActiveTcpConnections()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆