-1

I have a windows service application. I have placed all my codes inside a try block, but still the application crashes some times. Following is the error message i got from event viewer i'm not able to figure out anything from the code. Can anyone please assist me with this

Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: bgfcimportjobs.exe
P2: 1.0.0.12
P3: 4f8ee332
P4: mscorlib
P5: 2.0.0.0
P6: 4e1539fa
P7: 349e
P8: 1c5
P9: System.IO.IOException
P10: 

Attached files:

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_bgfcimportjobs.e_70609b5d8d50b31a8e1a14872a72bb7a82791b3a_2d2ac10e

Analysis symbol: 
Rechecking for solution: 0
Report Id: 1f7048c8-8f63-11e1-8875-b499ba03bf80
Report Status: 4

Thanks in advance!!!

Tim
  • 14,999
  • 1
  • 45
  • 68
Umamaheswaran
  • 3,690
  • 3
  • 29
  • 56
  • 2
    which might mean not all your code blocks are covered with try catch blocks. – adt Apr 26 '12 at 16:14
  • Since this is a service, I would really setup a global exception handler if it ever gets to that point. As you can tell, the exception doesn't help very much, whereas you can just write your own information to the system events and know where to look. Otherwise, there really isn't enough information to help you out. You have an uncaught exception, which means you should really take a strong look at your code and wrap dangerous sections in try/catch blocks. – SPFiredrake May 02 '12 at 19:10
  • try using http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx And this answer might give you a clue. http://stackoverflow.com/questions/1682128/global-exception-handler-for-windows-services – adt Apr 26 '12 at 16:23
  • it turns out that there were some issues with one of the open source code i used, that source didn't caught exception and didn't throw the exceptions. Finally i fixed it !!! Thanks for all your inputs!!! – Umamaheswaran May 24 '12 at 09:20

6 Answers6

1

Are you really sure that it is all within try-catch? You need to add it around all event handlers and anything like that.

As that is an IO exception, do you have any code that is reading/writing files?

Fiona - myaccessible.website
  • 14,481
  • 16
  • 82
  • 117
1

Your code is in a Try block, but do you have a Catch section after your try?

try
{
   some code...
}
catch(Exception e) 
{
    string message = e.Message;
}
Amaranth
  • 2,433
  • 6
  • 36
  • 58
  • Indeed. [try-catch](http://msdn.microsoft.com/en-us/library/0yd65esw.aspx): _"If no catch block is found, then the CLR displays an unhandled exception message to the user and stops execution of the program."_ – CodeCaster Apr 26 '12 at 16:31
  • You'll need either a `catch` or a `finally` block following a `try`. Otherwise you'll get a compile-time error. – Brian Rasmussen Apr 26 '12 at 16:53
0

Are you logging the caught exception somehow so that you can actually see what it is?

Also - you could run Debugger.Launch() - http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.launch.aspx - and step through it to see what is happening

Paula Bean
  • 458
  • 3
  • 9
0

Do you catch the right exceptions?
You should at least catch System.IO.IOException or a base class of it.
In catch block you should log the whole exception, i.e.:

try
{
  your code...
}
catch(IOException e) 
{
  YourLogger.WriteMessage(e);
}

So you get also the stack trace of exception.

brgerner
  • 4,287
  • 4
  • 23
  • 38
0

It could be that you're not catching the exception that your try block is throwing.

Susie
  • 5,038
  • 10
  • 53
  • 74
0

Open VS 2010. Go to Debug > Exceptions menu. Now select all the check box under Thrown category.

Execute the service and attach the process using Debug > Attach to Process.

Now, if any of the errors come, the execution will tell the code which raised the issue.

Romil Kumar Jain
  • 20,239
  • 9
  • 63
  • 92