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

  • SEARCH
  • Home
  • 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 8616953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:44:30+00:00 2026-06-12T05:44:30+00:00

I want a breakpoint to be hit when there is a certain method in

  • 0

I want a breakpoint to be hit when there is a certain method in the call stack.
Can I do this somehow with the Visual Studio debugger?

I want to be sure my breakpoint will be hit when the code is called from certain methods, but not others.

For example we have two call stacks:

DBReadRecord()
GetRecord()
ActivityMonitor()

and

DBReadRecord()
GetRecord()
UserButtonDown()

I want a breakpoint in DBReadRecord to be hit only when it is called from the UserButtonDown() method and not from the ActivityMonitor() method.

I am using Visual Studio 10 and .Net 3.5.

  • 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-06-12T05:44:31+00:00Added an answer on June 12, 2026 at 5:44 am

    You could also do some reflection-based hacking (for example, Express editions seem not to have advanced breakpoint functionalities):

        void Foo()
        {
            Foo2();
        }
        void Foo2()
        {
            var trace = new StackTrace();
            if (trace.GetFrames().Reverse().FirstOrDefault(f => f.GetMethod().Name == "Foo") != null)
                Debugger.Break(); // it lives under System.Diagnostics namespace
        }
        void Test()
        {
            Foo2(); // doesn't break here
            Foo(); // break here
        }
    

    And with your particular methods:

    Foo DBReadRecord()
    {
         var trace = new StackTrace();
         if (trace.GetFrames().Reverse().FirstOrDefault(f => f.GetMethod().Name == "UserButtonDown") != null)
             Debugger.Break();
    }
    

    Note that it greatly affects performance, so it’s only temporary solution for strange debugging situations.

    Also, remember that it works best in Debug configurations, I do not know what optimizations may occur that effect in method not being in StackTrace, but such thing can happen when optimizations are turned on.

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

Sidebar

Related Questions

In Visual Studio, I can start the debugger and am able to debug any
Is there an easy way to set conditional breakpoints in Visual Studio? If I
Yes, I see the other topic: Visual Studio Debugger - Automatic Variable Assignment But
I have a Visual Studio solution with four C# projects in it. I want
I want to debug a ASP.NET application (Custom IHttpHandler) with Visual Studio 2008 and
I want to put a conditional breakpoint in windbg. For example lets say LoadLibrary
I want to trace the source code , but when I set a breakpoint,
want to have a Hyperlink-Button in a gridView in which I can display a
Using Visual Studio 2008, to start debugging depending on my mood, I'll either attach to process
I want a code snippet editor for VS2008. I'd like to just hit a

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.