Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show complete exception error 1

Status
Not open for further replies.

robertfah

Programmer
Mar 20, 2006
380
US
I've got some code that stores any errors to our DB and emails us when it happens. Here's the simple call:

Code:
            catch (Exception ex)
            {
                if (System.Diagnostics.Debugger.IsAttached)
                    System.Diagnostics.Debugger.Break();
                else
                    Errors.InsertError(ex.ToString());
            }

The issue is, when we get an email, it's omitting the line number and the filename (somefilename.cs) from the exception, any ideas why?

Here's what the message looks like in our email:
System.NullReferenceException: Object reference not set to an instance of an object.
at SupportCenterSuite.frmMain.FormatGridIssues(Int32 iFocusRowHandle)


And here's what it looks like when I run it in Debug mode and put ex.ToString() in the Watch window:

System.NullReferenceException: Object reference not set to an instance of an object.
at SupportCenterSuite.frmMain.FormatGridIssues(Int32 iFocusRowHandle) in C:\Projects\VS 2010\Windows Apps\SupportCenterSuite\frmMain.cs:line 412
 
Hi,

if you run a program here are two modes you can start.
The debug mode and the release mode. In the debug mode are informations about the running environment stored. These informations include the execution filename and the linenumber.
In releasemode, these information is forperformance reasons not available. So the exception don't have the information ofthe filename and the linenumber, if you start the program normally.

If I don't miss, the additional informaion of the debug mode is sored in he *.pdb-files in the bin-directory. But I don't know away to include these files in the release mode. Possible, there is no way for this or it is a compiler setting (some other languages use coompiler settings to insert debuginformations).

I hope, I could help.

Kostarsus
 
Kostarsus,

Thanks for the help, it pointed me in the right direction. Within the project, if you right-click and choose Properties, then the Publish tab, then Application Files, there's a dialog box that appears. Makes sure to click the "Show all files" checkbox in the lower left corner. The .pdb files will then be displayed and can be included in the build.

This works and has helped me tremendously....Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top