0

We've been seeing this error crop up in our system event logs an alarming amount. It relates to a very simple command-line app (literally four or five lines of actual processing code) that consumes a webservice on the same machine. I modified the application configuration and it seemed to fix things, but now it's back.
The error only appears in the Event Viewer, and looks a little like this:

Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 19/09/2011
Time: 09:26:04
User: N/A
Computer: SQL
Description: EventType clr20r3, P1 estimatorcli.exe, P2 1.0.0.0, P3 4e410f1b, P4 mscorlib, P5 2.0.0.0, P6 4d8c128c, P7 420e, P8 51, P9 system.servicemodel.fault, P10 NIL.

Sorry if this is too much.
Googling hasn't brought back a whole lot of information, just some obscure references to the EventType. I've tried debugging, and a lot of the time, the program runs fine on my XP64 development machine (the server's running 2003 Ent64). However, when I update the Service Reference, Visual Studio creates two references to the Web Service, and when I try to run the app, it throws a nasty error that seems to indicate that the app can't determine which of the references it shoudl be using. Removing the surplus reference in the app.config file seems to cure this, but I've done this and moved the compiled app to the server and am still getting this error. I also find it interesting that the error is listed as being .Net 2.0 when the app was written for .Net 3.5; the server has .Net 3.5SP1 installed.
Could this be a Visual Studio bug? If so, could there be a way around it?
Thanks.
Update: From going through the stack trace, I was able to discover the error was my fault; I hadn't passed enough parameters through to a stored procedure. Looking back, I guess the entire framework was working as can be expected, I just wish the errors were easier to read!

Gargravarr
  • 635
  • 2
  • 10
  • 18
  • possible duplicate of [Deciphering the .NET clr20r3 exception parameters P1..P10](http://stackoverflow.com/questions/4052770/deciphering-the-net-clr20r3-exception-parameters-p1-p10) – Hans Passant Sep 19 '11 at 10:33
  • @Hans Passant I don't think it's a duplication; that question breaks down the expection but doesn't explain what causes the exceptions. That's not to say that link wasn't useful; it did shed a bit of light on what's going on. Thanks! – Gargravarr Sep 19 '11 at 11:11

2 Answers2

2

This is typically how the .NET runtime notifies you of an uncaught exception in your application.

Since you have a "simple command line application", try putting a try/catch block, together with writing the exception to the console, eventlog or some file.

Example:

public static int main(String[] args)
{
    try 
    {
       // other code

       return 0;
    }
    catch (Exception ex)
    {
       Console.Error.WriteLine(ex);

       // Save to file, in case this is an application that runs in the background
       // Make sure the directory exists and is writable though.
       System.IO.File.WriteAllText("C:\\TEMP\\Exception.txt", ex.ToString());

       return 1;
    }
}
Christian.K
  • 47,778
  • 10
  • 99
  • 143
  • Thanks for the hint. Looks like the WebServices were indeed throwing an uncaught exception, which is odd, since I thought I'd specifically caught everything. I've got a stack trace now, so I'll see where this exception is being thrown. Thanks! – Gargravarr Sep 19 '11 at 12:19
  • Okay... this is weird... I've read through the text file I created by catching the exception, and for some reason it looks like the app is trying to read the webservice.asmx.cs file on my collague's workstation (not my own!), which I find to be very strange. The stack trace lists the working path as being my colleague's SVN path. This is extremely strange, as a) this is running on the server, and b) I don't think he's ever even opened this project, let alone worked on it. The actual error is a casting error, but the line numbers aren't matching up, so this is going to take a while. – Gargravarr Sep 19 '11 at 12:26
  • You may update your question with the actual stacktrace. Also, the file paths you see in the stacktrace are those of the location where the app was compiled on (in this case your colleges workstation). – Christian.K Sep 19 '11 at 12:30
  • I guess that makes sense; he must have been the =last one to publish the webservices. Found the error too; I wasn't sending enough parameters to a stored procedure, so I guess everything was really working as it ought to be! – Gargravarr Sep 19 '11 at 12:40
0
  1. try to catch the exception and log
  2. try to use AppDomain.CurrentDomain.UnhandledException to catch unexpected exception and log.
unruledboy
  • 2,455
  • 2
  • 23
  • 30