2

I have a Windows Console application built in Visual Studio 2010 and it keeps crashing but the error is not caught by the visual studio debugging tool nor by try/catch statements in my code.

I have managed to locate the WER file on my system and would like to be able to understand the contents of the file so I can pinpoint exactally what is causing the unhandled exception.

I would be greatful if anyone can offer some idea on how I can use the following information to locate the process causing me this problem and also what the exception may be...

The information from the WER file is:

Version=1
EventType=APPCRASH
EventTime=129973086237604286
ReportType=2
Consent=1
ReportIdentifier=91331e8b-2dc8-11e2-977b-080027f7e5bb
IntegratorReportIdentifier=91331e8a-2dc8-11e2-977b-080027f7e5bb
WOW64=1
Response.type=4
Sig[0].Name=Application Name
Sig[0].Value=SAGE_TESTING.vshost.exe
Sig[1].Name=Application Version
Sig[1].Value=10.0.30319.1
Sig[2].Name=Application Timestamp
Sig[2].Value=4ba2084b
Sig[3].Name=Fault Module Name
Sig[3].Value=ntdll.dll
Sig[4].Name=Fault Module Version
Sig[4].Value=6.1.7600.16385
Sig[5].Name=Fault Module Timestamp
Sig[5].Value=4a5bdb3b
Sig[6].Name=Exception Code
Sig[6].Value=c015000f
Sig[7].Name=Exception Offset
Sig[7].Value=000845bb
DynamicSig[1].Name=OS Version
DynamicSig[1].Value=6.1.7600.2.0.0.272.7
DynamicSig[2].Name=Locale ID
DynamicSig[2].Value=2057
DynamicSig[22].Name=Additional Information 1
DynamicSig[22].Value=0a9e
DynamicSig[23].Name=Additional Information 2
DynamicSig[23].Value=0a9e372d3b4ad19135b953a78882e789
DynamicSig[24].Name=Additional Information 3
DynamicSig[24].Value=0a9e
DynamicSig[25].Name=Additional Information 4
DynamicSig[25].Value=0a9e372d3b4ad19135b953a78882e789

Here is the section of code I believe to be causing the exception to be thrown:

//Data from the project linked to the split data
if (oSplitData.Project != null)
{
    oProject = oSplitData.Project as SageDataObject190.Project;

    oBasicDetail.ProjectID = oProject.ProjectID;
    oBasicDetail.ProjectReference = oProject.Reference.ToString();
}
else
{
    oBasicDetail.ProjectID = -1;
    oBasicDetail.ProjectReference = "NO_PROJECT";
}

To add to all the above I seem to have found that there is a general exception that is being thrown but it doesn't help me out much - if anyone can put some light on this it would be great:

Unhandled exception at 0x78bc7361 in SAGE_TESTING.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
Cœur
  • 37,241
  • 25
  • 195
  • 267
Luke
  • 422
  • 5
  • 15
  • Could you post some code?. Maybe the exception is not caught but you can tell us the line where the app crash in debug? – Carlos Landeras Nov 13 '12 at 20:32
  • This looks like an access violation as opposed to an exception. – Dan Nov 13 '12 at 20:33
  • Are you running/compiling in Debug Mode? – Brad Semrad Nov 13 '12 at 20:33
  • Did you try going in Debug > Exceptions, then checking all checkboxes, and trying to debug again? – LMB Nov 13 '12 at 20:34
  • None of the information you posted can help you locate the problem. An exception has to be thrown. We need that information. – Security Hound Nov 13 '12 at 20:35
  • Hi all, thanks for your responses. I am running the application in debug mode and I have all the exceptions checked in the Debug settings. The line of code that I have narrowed it down to falling over when I am opening an IF statement looking to see if an object is equal to null or not. I will add the code to the listing. I am catching my exceptions in a Try/Catch statement but this is not catching the error and the error is being caught by the Visual Studio Just-In-Time debugger instead... – Luke Nov 13 '12 at 22:45

3 Answers3

3

If your program is multi-threaded and the exception is thrown in one of the spawned threads, the Exception may not be caught depending on how you do exception handling in your program.

You can add a catch-all exception handler like this:

class Program 
{
    static void Main(string[] args) 
    {
        AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
        // Your code here
    }

    static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) 
    {
        Console.WriteLine(e.ExceptionObject.ToString());
        Environment.Exit(1);
    }
}

UPDATE

Based on the code you posted, here are some things to look at

  • Put a try/catch block around the code you posted.
  • Are you sure that oSplitData is not null?
  • In the following line, oProject will be null if oSplitData.Project is not of type SageDataObject190.Project. Test for null.

    oProject = oSplitData.Project as SageDataObject190.Project;

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • I have tried this and it is still not catching my error in my code. I have removed all other error catching except this and tested and this still doesn't catch my error. It does work in catching errors in my code though as I have thrown a purpose error and it dealt with that error with no problem... – Luke Nov 13 '12 at 22:57
  • Hi Eric J - Thanks for these ideas but unfortunately I have tried all of these things and a few more different ideas as well (i.e. declaring the objects in different areas in my code as well as trying to work out if the oSplitData and oProject objects are null at different points in my code) - all to no avail. The other thing that is worth mentinoing is that this issue falls over intermittently and not consistently (i.e. sometimes it might fall over fairly quickly into running the code and other times it might fall over after processing many records)... – Luke Nov 14 '12 at 07:55
0

Are you invoking non-managed C++ or other code?

I'd try something like

static void Main()
{
  try
  {
    DoSomethingUseful() ;
  }
  catch ( Exception e )
  {
    // managed exceptions caught here
  }
  catch
  {
    // non-managed C++ or other code can throw non-exception objects
    // they are caught here.
  }
  return ;
}

See Will CLR handle both CLS-Complaint and non-CLS complaint exceptions?

Also C++ try, catch and throw statements at msdn: http://msdn.microsoft.com/en-us/library/6dekhbbc(v=vs.100).aspx

And MSIL opcode throw (0x7A) allows the throwing any object reference. C#, however, does not allow it.

But it looks like they improved things with .Net 2.0 and started wrapping oddball stuff in an RuntimeWrappedException.

Community
  • 1
  • 1
Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135
  • Do you have a link to more information about non-exception objects? I have never heard of that (I do not do much interop) and would like to read about it. – Eric J. Nov 13 '12 at 21:02
0

You are probably dealing with so-called corrupted state exceptions. These exceptions corrupt the process in a way so it is usually more safe to kill the process since it is very difficult to impossible to recover from such an error, even if it would be only for running a short catch-clause. Examples are StackOverflowExceptions, OutOfMemoryExceptions or AccessViolationExceptions.

There is an extensive and generally interesting explanation on corrupted state exceptions in this article.

What is helpful on getting a hand on such exceptions is to use DebugDiag. With this tool from Microsoft (download on this page) you can define a crash rule which generates a crashdump for your failed process. You can easily open these dump files in Visual Studio, where you may find the source of the exception that lead to the failure. This is not guaranteed but it often helped me in the past to nail down some nasty errors.

markus987
  • 301
  • 3
  • 8