tags:

views:

1333

answers:

1

Hi all,

I have encountered a rather odd error that I do not understand. I created a C# console application that was designed to just be a test to see if my web service was working from outside my network. All it did was try and connect to the webservice, output each stage to the console and write it to a text file so they could send me the logs.

It worked perfectly on 3 XP machines (one inside my network, 2 outside). A Vista machine (had a manifest file) but on my bosses XP machine (he is an IT guy so does know what he is doing), it threw a very odd error.

C:\temp\testwe~1.exe The NTVDM CPU has encountered an illegal instruction

http://www.houseofhawkins.com/roger.jpg" />

I did some googling and it seemed like his NTVDM might have been buggered, or there was a virus or something. None of these seem to be the case. I can not see what would be happening to cause this to fail in such a way.

using System; using System.Collections.Generic; using System.Text; using System.IO;

namespace testwebservice { class Program { FileStream theFile = null; StreamWriter writer = 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);
        }
    }
}

}

I am very stuck why the above code could / would do this. It is sort of just I want to know and partly, could this happen to a real clients machine, or just is my bosses machine infected or something.

Thank you

+1  A: 

Something is very wrong if you end up in NTVDM, as this is the 16-bit DOS emulation layer for XP. If this happens again after you recopy the EXE across, I'd investigate the software installed on your boss's PC (.NET framework version, etc).

I'd also try running this in WinDbg to see where you end up, get a call stack once it faults out etc, I bet you'll find a strange module on the stack (spyware, etc).

Paul Betts
I think he has tried a copy of copies of the EXE which had the same effect, (different versions, more logging was added to try and get an answer). I will give the debug bit a go. Thanks
Jon