我遇到了一个我不明白的相当奇怪的错误。我创建了一个 C# 控制台应用程序,旨在测试我的 Web 服务是否在我的网络外部工作。它所做的只是尝试连接到 Web 服务,将每个阶段输出到控制台并将其写入文本文件,以便他们可以将日志发送给我。
它在 3 台 XP 机器上运行良好(一台在我的网络内,两台在我的网络外)。一台 Vista 机器(有一个清单文件)但在我老板的 XP 机器上(他是一名 IT 人员,所以知道他在做什么),它抛出了一个非常奇怪的错误。
C:\temp\testwe~1.exe NTVDM CPU遇到非法指令
http://www.houseofhawkins.com/roger.jpg">
我做了一些谷歌搜索,看起来他的 NTVDM 可能被窃听了,或者有病毒什么的。这些似乎都不是。我看不出会发生什么导致它以这种方式失败。
使用系统;使用 System.Collections.Generic;使用 System.Text;使用 System.IO;
命名空间 testwebservice { 类程序 { FileStream theFile = null; StreamWriter 作家 = null;
static void Main(string[] args)
{
Program p = new Program();
p.testMe();
}
private void testMe()
{
Console.WriteLine("Entered main method about to create stream");
try
{
theFile = File.Create(@"jonTestWebService.log");
writer = new StreamWriter(theFile);
writer.AutoFlush = true;
try
{
message("Starting test at: " + DateTime.Now.ToLongTimeString());
Random rand = new Random();
message("creating new instance of webservice");
houseofhawkins.testweb webServ = new testwebservice.houseofhawkins.testweb();
message("calling hello world");
String helloResult = webServ.HelloWorld();
message("hello world result = " + helloResult);
int one = rand.Next(999);
int two = rand.Next(999);
message("calling maths method with " + one + " + " + two);
String mathResult = webServ.mytestMethod(one, two);
message("Math result is: " + mathResult);
message("Creating instance of CSJawbreaker");
CSJawbreaker.InformationService csj = new testwebservice.CSJawbreaker.InformationService();
message("trying to get the latest version number");
float version = csj.latestVersionNumber();
message("Version number: " + version.ToString());
message("");
message("Finished all processing at: " + DateTime.Now.ToLongTimeString());
}
catch (Exception ex)
{
writer.WriteLine("");
writer.WriteLine(ex.Message);
writer.WriteLine("");
}
}
catch (Exception ex)
{
Console.WriteLine("could not create stream Writer, " + ex.Message);
}
message("");
message("Press return to exit");
Console.ReadLine();
writer.Close();
theFile.Close();
}
private void message(String message)
{
if (theFile != null && writer != null)
{
Console.WriteLine(message);
writer.WriteLine(message);
}
}
}
}
我很困惑为什么上面的代码可以/会这样做。这只是我想知道的部分,这可能会发生在真正的客户机器上,还是只是我老板的机器被感染了或其他什么。
谢谢