Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add break point to default constructor

I have a class, which has a default constructor inherently.

public class OneRollingFileAppender : RollingFileAppender
{
    #region RollingFileAppender Overrides

    protected override void Append(LoggingEvent loggingEvent)
    {

        GlobalFactory<ILoggingEventParameterManager>.Instance.Apply(loggingEvent);
        base.Append(loggingEvent);
    }

    #endregion
}

Without editing the code, e.g adding a new constructor or property, how can I breakpoint default constructor?

NOTE: There should be a technique which will to find the code in IL or in memory, and then I'd like to set a breakpoint there.

like image 585
johnny 5 Avatar asked Sep 03 '25 03:09

johnny 5


1 Answers

Use WinDbg + SOS Extension

  1. Attach to the process with Windbg (File/Attach to process)

  2. load sos (.loadby sos mscorwks)

  3. Set the breakpoint ( !bpmd mylib.dll Namespace.ClassName..ctor )

If you just want to know when the class is created you can make use of a function breakpoint within Visual Studio. Debug -> New Breakpoint

enter image description here

As Function name you enter your class name.

like image 196
Postlagerkarte Avatar answered Sep 06 '25 01:09

Postlagerkarte