简体   繁体   English

使用Ping .net进行内存转储

[英]Memory dump using Ping .net

I'm trying to do a ping to a server in a Windows Forms Application but when my program is running, I have memory dump on my computer. 我正在尝试对Windows Forms应用程序中的服务器执行ping操作,但是当我的程序运行时,我的计算机上有内存转储。 Very, very strange. 非常非常奇怪

In my method I only have: 在我的方法中,我只有:

private void CheckServer()
{
    this.txResponse.Text = "";

    IPAddress IpAdress = IPAddress.Parse("anAdress");
    Ping ping = new Ping();

    PingReply pingToReply = ping.Send(IpAdress);

    if (pingToReply.Status == IPStatus.Success)
        txResponse.Text = pingToReply.Status.ToString();
}

I really don't understand what is going on. 我真的不明白发生了什么。 I'm using Visual Studio 2012 with .NET Framework 4.5 on Windows 8.If it is necessary more information, please let me know. 我正在Windows 8上使用Visual Studio 2012和.NET Framework 4.5,如果需要更多信息,请告诉我。

Verify that the parsing of the IP Address is successful; 验证IP地址的解析是否成功; otherwise check the surrounding processing outside of the CheckServer method. 否则,请检查CheckServer方法之外的周围处理。

Ahhh, the joys of programming having a program blow up when there is absolutely nothing wrong with the code... (your code looks fine other than putting a try/catch block around it) 啊,当代码绝对没有错的时候,编写程序的乐趣就消失了……(您的代码看起来不错,除了在其周围放置了try / catch块之外)

It could be a hardware issue (memory, disk etc), bad dll, or any number of things that go bump in the night. 可能是硬件问题(内存,磁盘等),错误的dll或夜晚发生的许多事情。 I assume you have tried rebooting your computer, and pinging your server at the DOS prompt. 我假设您已尝试重新启动计算机,并在DOS提示符下ping服务器。 If not do so. 如果不是这样。

One thing you could try is to call ping.exe directly with a command line/ip of your choice synchronously or asynchronously, see http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C and then parse the output to get what you need (lines starting with "Reply from" or "Request timed out." or even the % loss line. 您可以尝试做的一件事是使用您选择的命令行/ ip直接或异步地直接调用ping.exe,请参阅http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command- in-C ,然后解析输出以获取所需内容(以“答复自”或“请求超时”开头的行,甚至%损失行。

Another thing to try is bypass the c# Ping and PingReply calls entirely and use net sockets and a timer, see http://sourceforge.net/projects/pingutil/?source=typ_redirect particularly the ping.cs file. 可以尝试的另一件事是完全绕过c# PingPingReply调用,并使用网络套接字和计时器,请参阅http://sourceforge.net/projects/pingutil/?source=typ_redirect特别是ping.cs文件。

These solutions would allow you to potentially write around the problem, but it does not necessarily solve the problem at hand, which does not appear to programming related from the code you have provided. 这些解决方案可以使您潜在地解决问题,但是不一定解决当前的问题,对于您提供的代码进行的编程而言,这似乎并不可行。

OK, other thoughts... 1)Do a rebuild all on your project 2) Try compiling using an older version of .NET 3) Create a new project and copy block the source into the newly created files. 好吧,其他想法... 1)对项目进行全部重建2)尝试使用旧版本的.NET进行编译3)创建一个新项目并将源代码复制到新创建的文件中。 4) run the project on another computer to see if you get the same results. 4)在另一台计算机上运行该项目,看看是否得到相同的结果。 Any exception error that may or may not be generated should never cause a core dump. 可能会或可能不会生成的任何异常错误都决不会导致核心转储。

Yet another option is to analyze the core dump, for an application, see: http://sourceforge.net/projects/core-analyzer/ and also check out Tool for analyzing java core dump 另一个选择是分析核心转储,对于应用程序,请参见: http : //sourceforge.net/projects/core-analyzer/并还签出了用于分析Java核心转储的工具

Worse comes to worse, you may have to reload Visual Studio and/or .NET. 更糟的是,您可能必须重新加载Visual Studio和/或.NET。

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

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