I encountered a problem.
I noticed that a Property (say MyProp) in my program is being invoked continuously by the main thread. In spite of a breakpoint is inserted at its get accessor scope, the code isn’t broken at that point! (Why?)
So I couldn’t check the call stack to find out which part of my code is invoking that property on and on. I tried to chack the stack trace manually as follows:
public static MyType MyProp {
get {
string threadName = Thread.CurrentThread.Name;
string MTID = Thread.CurrentThread.ManagedThreadId;
Debug.WriteLine("» MyProp");
Debug.Indent();
Debug.WriteLine("Current Thread : MTID = " + MTID + ", Name = " + threadName);
StackTrace stack = new StackTrace();
Debug.WriteLine("Frame Count : " + stack.FrameCount);
for (int index = 0; index < stack.FrameCount; index++)
{
StackFrame frame = st.GetFrame(index);
string methodName = frame.GetMethod().Name;
Debug.WriteLine(string.Format("Frame [{0}]: Method = '{1}'", index + 1, methodName));
}
Debug.Unindent();
// Rest of code..
}
}
Also, I searched the MyProp symbol in entire solution and then used the System.Diagnostics.Debug.WriteLine method wherever this property is invoked, but none of them is written at the Output window!! (How could this be possible?)
By pressing F11 key, (i.e. to start my prog from the very beginning point) and right after required dll-s were loaded, I see the following lines in the Output window:
'MyProg.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System....dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
:
'MyProg.vshost.exe' (Managed): Loaded 'D:\...\My Prog\bin\Debug\MyProg.exe', Symbols loaded.
'MyProg.vshost.exe' (Managed): Loaded 'D:\...\My Prog\bin\Debug\part1.dll', Symbols loaded.
:
'MyProg.vshost.exe' (Managed): Loaded 'D:\...\My Prog\bin\Debug\partn.dll', Symbols loaded.
» MyProp
Current Thread : MTID = '9', Name = '' // <- Main thread
Frame Count : 6
Frame [1]: Method = 'get_MyProp' // <- How???
Frame [2]: Method = 'Main'
Frame [3]: Method = '_nExecuteAssembly'
Frame [4]: Method = 'RunUsersAssembly'
Frame [5]: Method = 'Run'
Frame [6]: Method = 'ThreadStart'
The annoying thing is that every once I go one step ahead (By pressing F10 or F11 key), I see the » MyProp log section again!!!
What could be causeing this and how can I treat this issue? _Thanks
How to get all callers?
If you have ReSharper you can get all call stacks without debugging by placing cursor on your property and pressing Ctrl+Shift+Alt+A and selecting Incoming Calls. (See http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Call_Tracking.html).
Here is an example of Inspection Results view:

Or just use Visual Studio built-in feature: Call Hierarchy. Right-click member and select View Call Hierarchy. Example view:
How to set break point within properties?
Update1: I can debug into properties on my machine (VS2010). My debugging options are:
and