AlexBB

In a massive chunk of about 25,000 lines of C# source code it is very difficult to find where breakdown occured at runtime when I get a message: Object reference not set to an instance of an object. A lot of guess work is necessary since it can happen anywhere.

I suspect there is a way to set up System.Diagnostics classes that would give me information on the precise place where it happened in a file or at Console. How can I do it

I would appreciate any help.

Thanks.




Re: Visual C# IDE Debug problem.

John.Doe

If you start the program from Visual Studio just start it with "Debug > Start Debugging" if it bombs out, the debugger will highlight the piece of code to you where the exception occured.



Re: Visual C# IDE Debug problem.

Colin Burn

Is this in release mode

If you distribute pdb files with your application then exceptions will contain meaningful stack traces associated with them. To include pdb files you will have to switch on the debug output in the project properties under build->advanced.

You might also want to look at implementing an unhandled exception handler to catch exceptions and log them as your application crashes.

http://msdn2.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx





Re: Visual C# IDE Debug problem.

AlexBB

If you start the program from Visual Studio just start it with "Debug > Start Debugging" if it bombs out, the debugger will highlight the piece of code to you where the exception occured.

It never happens with this particular type of error. Never. I suspect that a special parameter in the debug mode or while instantiating the Debug class must be set but I could not find one.

I repeat, in my application which is still in Debug mode I never ever see code highlighted when an object is null. I see it with many other errors but not this one.

StepInto (F11), StepOut (SHIFT+F11) and StepOver (F10) are not helpful either. When I start the app I can use them only until the from shows up. After I pressed any button I have no control over the code run. Those options are not longer available.

Thanks.






Re: Visual C# IDE Debug problem.

AlexBB

 Colin Burn wrote:

Is this in release mode

If you distribute pdb files with your application then exceptions will contain meaningful stack traces associated with them. To include pdb files you will have to switch on the debug output in the project properties under build->advanced.

You might also want to look at implementing an unhandled exception handler to catch exceptions and log them as your application crashes.

http://msdn2.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx

It is a debug, pure debug situation. I still have enough trouble with it before I release anything.

I used your link, set up Class Test and started the Example routine in my main and found that it gives me no advantage. Number one, in those messages I've been getting, I've never seen a claim that the exceptions are unhandled.

I do not distribute anything let alone pdb files. I won't mind to find out how the symbol files can be set up and used. I have tons of them in my directories but have no idea how to use them.

I guess I have to read upon it. The situation has become intolerable. The only way so far for me to locate a bug was to insert a Console.WriteLine statement in various places. It is getting ridiculous.

Thanks.






Re: Visual C# IDE Debug problem.

Friendly Dog

"When I start the app I can use them only until the from shows up. After I pressed any button I have no control over the code run. Those options are not longer available."

I wonder what do you mean... You can set up a break-point on button click handler and after you click the button, you'll be able to trace the code...






Re: Visual C# IDE Debug problem.

AlexBB

Friendly Dog wrote:

I wonder what do you mean... You can set up a break-point on button click handler and after you click the button, you'll be able to trace the code...

Sometimes I wonder what I mean myself. How could I to have gotten so engrossed with the problem that I forgot about breakpoints.

That's why this forum is so helpful. It saves us from ourselves.

Thanks.