473,770 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exceptions after compile to Release

I am working with Exceptions and have found a bit of a problem for me.
Using the code below in Debug I get the info I want which is basically:
-Line of error
-Column of error
-Method where error happened

However, when you compile to Release version you get no line or column
numbers. So I assume this is because the .pdb file holds all of the info
regarding the lines and columns or something to that order. I am not
really to sure what the .pdb file actually holds.

So what I am after is a way to track down the exact place the error
happened without having to put a try...catch block everywhere in my
code. Am I going about this all wrong?

Also please note the code below is simply me playing and is in no way
complete or even ready for release. Also I should note that I am running
this by pressing F5 in VS.Net 2003 with DotNet Framework 1.1.

TIA
-Stanley

Expand|Select|Wrap|Line Numbers
  1. Imports System.Diagnostics
  2. Public Class _default
  3. Inherits System.Web.UI.Page
  4.  
  5. #Region " Web Form Designer Generated Code "
  6.  
  7. 'This call is required by the Web Form Designer.
  8. <System.Diagnostics.DebuggerStepThrough()> Private Sub
  9. InitializeComponent()
  10.  
  11. End Sub
  12.  
  13. 'NOTE: The following placeholder declaration is required by the Web
  14. Form Designer.
  15. 'Do not delete or move it.
  16. Private designerPlaceholderDeclaration As System.Object
  17.  
  18. Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
  19. System.EventArgs) Handles MyBase.Init
  20. 'CODEGEN: This method call is required by the Web Form Designer
  21. 'Do not modify it using the code editor.
  22. InitializeComponent()
  23. End Sub
  24.  
  25. #End Region
  26.  
  27. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
  28. System.EventArgs) Handles MyBase.Load
  29. Dim a As Integer = 0
  30. Dim b As Integer
  31. Try
  32. b = 1 \ a
  33. Catch ex As Exception
  34. Dim sf As New StackFrame(True)
  35. Dim st As New StackTrace(sf)
  36. Response.Write(ex.ToString.Replace(vbCrLf, "<br>"))
  37. Response.Write("<br>")
  38. Response.Write("Line #: " & st.GetFrame(0).ToString())
  39. Response.Write("<br>")
  40. Response.Write("Line #: " & st.GetFrame(0).GetFileLineNumber())
  41. Response.Write("<br>")
  42. Response.Write("Column #: " &
  43. st.GetFrame(0).GetFileColumnNumber())
  44. Response.Write("<br>")
  45. Response.Write("Method : " & st.GetFrame(0).GetMethod().Name)
  46. End Try
  47.  
  48.  
  49. End Sub
  50.  
  51. End Class
  52.  
[debug results]
System.DivideBy ZeroException: Attempted to divide by zero.
at pcTracker._defa ult.Page_Load(O bject sender, EventArgs e) in
C:\Inetpub\wwwr oot\pcTracker\d efault.aspx.vb: line 28
Line #: Page_Load at offset 131 in file:line:colum n
C:\Inetpub\wwwr oot\pcTracker\d efault.aspx.vb: 30:17
Line #: 30
Column #: 17
Method : Page_Load
[/debug results]

[release results]
System.DivideBy ZeroException: Attempted to divide by zero.
at pcTracker._defa ult.Page_Load(O bject sender, EventArgs e)
Line #: Page_Load at offset 128 in file:line:colum n :0:0
Line #: 0
Column #: 0
Method : Page_Load

[/release results]
Jul 21 '05 #1
1 1904
Well after some research I have found that what I want to do is not
actually possible. I guess I can live with the method that the error is
in using the "GetMethod" method, but what about the page? Below is what
I have come up with as a guide to what can be used as far as the methods
of the StackFrame. Hope it saves someone the trouble I went through.

-Stanley

Equals (inherited from Object) - Debug and Release
GetFileColumnNu mber - Debug Only
GetFileLineNumb er - Debug Only
GetFileName - Debug Only
GetHashCode - Debug and Release
GetILOffset - ???
GetMethod - Debug and Release
GetNativeOffset - ???
GetType - Debug and Release
ToString - Debug and Release

Stanley wrote:
I am working with Exceptions and have found a bit of a problem for me.
Using the code below in Debug I get the info I want which is basically:
-Line of error
-Column of error
-Method where error happened

However, when you compile to Release version you get no line or column
numbers. So I assume this is because the .pdb file holds all of the info
regarding the lines and columns or something to that order. I am not
really to sure what the .pdb file actually holds.

So what I am after is a way to track down the exact place the error
happened without having to put a try...catch block everywhere in my
code. Am I going about this all wrong?

Also please note the code below is simply me playing and is in no way
complete or even ready for release. Also I should note that I am running
this by pressing F5 in VS.Net 2003 with DotNet Framework 1.1.

TIA
-Stanley

Expand|Select|Wrap|Line Numbers
  1.  Imports System.Diagnostics
  2.  Public Class _default
  3.      Inherits System.Web.UI.Page
  4.  #Region " Web Form Designer Generated Code "
  5.      'This call is required by the Web Form Designer.
  6.      <System.Diagnostics.DebuggerStepThrough()> Private Sub
  7.  InitializeComponent()
  8.      End Sub
  9.      'NOTE: The following placeholder declaration is required by the Web
  10.  Form Designer.
  11.      'Do not delete or move it.
  12.      Private designerPlaceholderDeclaration As System.Object
  13.      Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
  14.  System.EventArgs) Handles MyBase.Init
  15.          'CODEGEN: This method call is required by the Web Form Designer
  16.          'Do not modify it using the code editor.
  17.          InitializeComponent()
  18.      End Sub
  19.  #End Region
  20.      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
  21.  System.EventArgs) Handles MyBase.Load
  22.          Dim a As Integer = 0
  23.          Dim b As Integer
  24.          Try
  25.              b = 1 \ a
  26.          Catch ex As Exception
  27.              Dim sf As New StackFrame(True)
  28.              Dim st As New StackTrace(sf)
  29.              Response.Write(ex.ToString.Replace(vbCrLf, "<br>"))
  30.              Response.Write("<br>")
  31.              Response.Write("Line #: " & st.GetFrame(0).ToString())
  32.              Response.Write("<br>")
  33.              Response.Write("Line #: " & st.GetFrame(0).GetFileLineNumber())
  34.              Response.Write("<br>")
  35.              Response.Write("Column #: " &
  36.  st.GetFrame(0).GetFileColumnNumber())
  37.              Response.Write("<br>")
  38.              Response.Write("Method : " & st.GetFrame(0).GetMethod().Name)
  39.          End Try
  40.      End Sub
  41.  End Class
  42.  

[debug results]
System.DivideBy ZeroException: Attempted to divide by zero.
at pcTracker._defa ult.Page_Load(O bject sender, EventArgs e) in
C:\Inetpub\wwwr oot\pcTracker\d efault.aspx.vb: line 28
Line #: Page_Load at offset 131 in file:line:colum n
C:\Inetpub\wwwr oot\pcTracker\d efault.aspx.vb: 30:17
Line #: 30
Column #: 17
Method : Page_Load
[/debug results]

[release results]
System.DivideBy ZeroException: Attempted to divide by zero.
at pcTracker._defa ult.Page_Load(O bject sender, EventArgs e)
Line #: Page_Load at offset 128 in file:line:colum n :0:0
Line #: 0
Column #: 0
Method : Page_Load

[/release results]

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3397
by: Robert Rotstein | last post by:
It appears that exception handling at the top-most level of a C# program, in the static void Main() method, differs depending on whether the program is run in debug mode or not. That is, code such as the following try { Application.Run(new something()); } catch
12
6116
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls out of which unmanaged exception //get thrown
11
1493
by: Tamas Demjen | last post by:
I was shocked to learn that VC++ 2005 Beta 2 can't catch Access Violation exceptions in unmanaged code. To reproduce this, I created a minimal Win32 console application: #include "stdafx.h" int _tmain(int argc, _TCHAR* argv) { int* p = 0;
1
279
by: Stanley | last post by:
I am working with Exceptions and have found a bit of a problem for me. Using the code below in Debug I get the info I want which is basically: -Line of error -Column of error -Method where error happened However, when you compile to Release version you get no line or column numbers. So I assume this is because the .pdb file holds all of the info regarding the lines and columns or something to that order. I am not really to sure what...
0
2034
by: Jérôme Le Bougeant | last post by:
Hello (and sorry for my English), I downloaded the VideoCapture module on the http://videocapture.sourceforge.net/ site. I tested it with a webcam and that functions. Now I want to compile his file .cpp (vidcap.cpp). Thereafter, the idea is to be able to modify the code to include my own modifications.
29
2521
by: mailforpr | last post by:
Sometimes, I can't think of any good reason why I should have the program's logic thrown an exception. Except for catching the exception and printing "Uh, oh" to the screen. I also think that in most cases there's simply no way to handle an exception properly, because what can one do about an integer overflow? Reassign values? Restart the program? The problem will still be existing. I think that an integer overflow is not an exception, but...
6
2363
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the problem also with other imports (e.g. urllib2 etc.). And again very often in all these cases where I get weired Python exceptions, the problem is around re-functions - usually during re.compile calls during import (see some of the exceptions below). But...
1
374
by: Daniel | last post by:
do release builds have the same amount of info in exceptions? e.g. will exceptions cought in release builds contain stack trace etc.?
22
2604
by: ben mitch | last post by:
Hi I hope you'll see this cross-post (c/c++) as appropriate. I also admit immediately that the question *may* turn out to be compiler-/os-specific, in which case I apologize. But I wonder if there's an underlying truth. We are writing a (cross-platform) 'framework' application (in C++, as it happens) that allows users to author 'plugins' (as shared library modules). Since the lifetime of plugins is expected to be long, and the
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.