Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I am writing a little error Handler into all my subs and functions that will dump the error to a text file and continue, this is when the application is compiled and running on client machines.

 

However I dont want to do that when I am debugging, I want to go to the line and debug as I normally would.

 

So I have a couple of questions:

 

1.) Is there a way to tell if the application is running out of Visual Studio?

2.) Is there a way to pause the code when an error occurs:

 

eg:

 

Try
   'My Code Goes Here
Catch ex as exception
    if INVISUALSTUDIO then
          'Pause Execution HERE to Do SOme Stuff
    end if
    ProcessError(Ex.Source, Ex.StackTrace, Ex.Message)

end try

  • Leaders
Posted

I think that there is a VB.NET Stop keyword that will send the execution to break mode in Visual Studio.

'The Stop keyword
Stop

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
You can always stop the execution of an app using the break mode of Visual Studio (normally a F9 key), there you can manage to see the values stored on variables, objects, threads, etc.
Fat kids are harder to kidnap
  • Leaders
Posted

And why not? You can automatically insert a Stop statement with the Visual Studio Replace.

Replace:

ProcessError

with

Stop: ProcessError

and to revert it, replace:

Stop: ProcessError

with Process Error. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • *Experts*
Posted (edited)

When compiling you can use the DEBUG compiler value. First you have to use the special If statement which is only read by the compiler. It looks like this:

#If DEBUG Then
    'do something if the program is compiled in DEBUG mode.
#End If

This kind of If statement will not be included in your program but rather the compiler will decide which code to compile based on the build configuration.

To apply it to your program you would have to use DEBUG build for testing and RELEASE for distribution (which is the setup you should be using :D). It would look like this:

Catch ex As Exception
    #If DEBUG Then
          Stop
    #Else
           'Process the error
    #End If
End Try

Edited by mutant

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...