Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7072697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:50:25+00:00 2026-05-28T05:50:25+00:00

Is it possible to automatically return from a function using a Breakpoint/Tracepoint? I don’t

  • 0

Is it possible to automatically return from a function using a Breakpoint/Tracepoint?
I don’t want to drag the execution point or set it with CTRL+SHIFT+F10 every time the breakpoint is hit.
I tried “printing” the following “messages” When Hit, but the executions continue without change.

{return;}
{return null;}

Note that I need to return from the function without actually changing code.

To clarify what a Tracepoint is: “A tracepoint is a breakpoint with a custom action associated with it. When a tracepoint is hit, the debugger performs the specified tracepoint action instead of, or in addition to, breaking program execution.” From MSDN.

If you don’t know what I mean with “printing messages”, you might want to read this AltDevBlogADay post about Tracepoints. It’s good.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:50:26+00:00Added an answer on May 28, 2026 at 5:50 am

    Okay, after a bit of digging around you can do this – but it’s not going to work in all cases.

    Beware, this uses macros and can’t be guaranteed to work with inline delegates; or with methods that actually need to return something. It automates the process described by @juergen d and @Erno when a breakpoint is hit; using very simple heuristics to find where the end of the current function is.

    You first need to add this macro to your macros environment (open with ALT+F11 in VS). This code is probably not as good as it could be as I’ve just rushed it out 🙂

    Sub ExitStack()
        'get the last-hit breakpoint
        Dim breakPoint As EnvDTE.Breakpoint
        breakPoint = DTE.Debugger.BreakpointLastHit()
        'if the currently open file is the same as where the breakpoint is set
        '(could search and open it, but the debugger *should* already have done that)
        If (DTE.ActiveDocument.FullName = breakPoint.File) Then
    
            Dim selection As EnvDTE.TextSelection = DTE.ActiveDocument.Selection
            Dim editPoint As EnvDTE.EditPoint
            'move the cursor to where the breakpoint is actually defined
            selection.MoveToLineAndOffset(breakPoint.FileLine, breakPoint.FileColumn)
    
            Dim codeElement As EnvDTE.CodeElement
            codeElement = DTE.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(selection.ActivePoint, vsCMElement.vsCMElementFunction)
            'if a function is found, move the cursor to the last character of it
            If Not (codeElement Is Nothing) Then
                Dim lastLine As EnvDTE.TextPoint
    
                lastLine = codeElement.GetEndPoint()
                selection.MoveToPoint(lastLine)
                selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
                'execute the SetNextStatement command.  
                'Has to be done via ExecuteCommand
                DTE.ExecuteCommand("Debug.SetNextStatement")
            End If
        End If
    End Sub
    

    With that in place, now you can set your breakpoint – right click on it and hit the When hit... menu option (this only works in VS2010 I believe). ScottGu describes this in this blog post.

    From the dialog, find the ExitStack macro that you’ve just pasted in.

    Run the code with the debugger attached and when the breakpoint is hit the rest of the function’s code should be skipped. This should obey other debugger tricks – like conditions etc.

    Note – I used this SO to solve a problem I was having; originally I was invoking the debugger’s SetNextStatement method directly and it didn’t work

    I have no idea how methods that should return will behave – in theory they should return whatever the return value local is at the time, but in some cases the fact is this simply won’t work!

    Equally if the breakpoint is in a try/catch block then it won’t work – because the try/catch has to be exited before you can set the next statement to somewhere outside of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to automatically create Word documents which include list fields from a
I am using Eclipse to develop a Blackberry Java application.Is possible to automatically increment
While it is possible to generate PowerPoint presentations automatically using Office Automation , this
Is it possible when using TFS server to automatically have it ensure a specific
Is it possible in Word 2007 to create a revision history table automatically using
I am using linq to sql , and I return a queryable result from
Is this possible? I return the time that something was posted via PHP function
is it possible to automatically export mysql database in phpmyadmin
Is it possible to automatically encrypt files via 'git push' before transferring to a
Is it possible to convert an existing WPF Application to SilverLight automatically/with minimal effort?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.