Reputation: 21015
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.
Upvotes: 4
Views: 1816
Reputation: 7117
Use WinDbg + SOS Extension
Attach to the process with Windbg (File/Attach to process)
load sos (.loadby sos mscorwks)
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
As Function name you enter your class name.
Upvotes: 4
Reputation: 5018
You can't put a breakpoint in compiled code that you don't control. However, with something like ReSharper, you can step into third party code. See: https://www.jetbrains.com/help/resharper/Debugging_Without_Source_Code.html
Upvotes: 0
Reputation: 46
I believe you are using log4net. As you don't have source code so you cannot put break point on your constructor.
Upvotes: 0
Reputation: 4395
If you create a variable and assign a value in your class you can place a break point there which will be hit when an instance of the class is created.
public class OneRollingFileAppender : RollingFileAppender
{
int foo = 0; //Place break point here
}
Upvotes: 2