Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug on a property's set in Visual studio 2010? [duplicate]

Let's say I have this property

public ISetting Setting { get; set; }

How can I get breakpoint at the set? So that the program will pause when something is setting a value.

I try to make it this way

public IDatabaseConnectionSetting ConnectionSetting { 
    get; 
    set;
}

And put the breakpoint on the set; line, but still it doesn't work. The red breakpoint highlighter highlights the whole property declaration

like image 729
Louis Rhys Avatar asked Aug 25 '11 02:08

Louis Rhys


People also ask

How do I debug multiple solutions in Visual Studio?

Press F5 and start debugging the solution B instance of Visual Studio. Then press F5 and start debugging the solution A instance of Visual Studio. Now both the instances of Visual Studio will be in debug mode.

How do I set debug configuration in Visual Studio?

In Solution Explorer, right-click the project and choose Properties. In the side pane, choose Build (or Compile in Visual Basic). In the Configuration list at the top, choose Debug or Release. Select the Advanced button (or the Advanced Compile Options button in Visual Basic).

How do I debug existing project in Visual Studio?

Launch configurations# To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file.

How debug DLL from another solution in Visual Studio?

Debug from the DLL project Set breakpoints in the DLL project. Right-click the DLL project and choose Set as Startup Project. Make sure the Solutions Configuration field is set to Debug. Press F5, click the green Start arrow, or select Debug > Start Debugging.


2 Answers

There's a better solution here: Can't set breakpoints on an auto-property setter ? Why?

Using Visual Studio 2008, 2010, 2012:

  1. Go to the Breakpoint window

  2. New->Break at Function…

  3. For the get, type: ClassName.get_CurrentFramesize()

    For the set, type: ClassName.set_CurrentFramesize(int)

You'll get a "No Source Available" when the breakpoint is hit, but you'll get the calling >location in the call stack.

I found this solution here: http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/b1dd0dc3-e9c1-402a-9c79-a5abf7f7286a

See also: Debugging automatic properties

like image 196
Bochu Avatar answered Sep 29 '22 10:09

Bochu


Use a full property rather than autoproperty.

The shortcut is propfull

private ISetting setting;

public ISetting Setting 
{ 
    get 
    { 
        return setting; 
    }
    set 
    { 
        setting = value; 
    }
} 

To use the code-snippet shortcut, type propfull and then press TAB twice.

like image 20
Kirk Broadhurst Avatar answered Sep 29 '22 08:09

Kirk Broadhurst