Hi John,
I made a simple application that executes the specific line that hangs.
My application exists of 2 classes.
FIRST CLASS: Name = MAIN.CS
using System;
namespace StackTraceTest
{
public class MainClass
{
[STAThread]
static void Main()
{
Processing processingClass = new Processing();
Console.WriteLi ne("BEFORE CALL TO PROCESSING");
processingClass .CreateStackTra ce();
Console.WriteLi ne("AFTER CALL TO PROCESSING");
}
}
}
SECOND CLASS: Name = Processing.cs
using System;
using System.Reflecti on;
using System.Diagnost ics;
namespace StackTraceTest
{
public class Processing
{
public Processing()
{
}
public void CreateStackTrac e()
{
Console.WriteLi ne("BEFORE CREATION OF STACKTRACE");
StackTrace stackTrace = new StackTrace(fals e);
Console.WriteLi ne("AFTER CREATION OF STACKTRACE");
int stackOffset = GetCallerStackO ffset(stackTrac e);
StackFrame stackFrame = stackTrace.GetF rame(stackOffse t);
int callerOffset = stackTrace.Fram eCount - stackOffset;
}
private int GetCallerStackO ffset(StackTrac e pStackTrace)
{
int stackOffset = 0;
// Lookup for the method of the object speaker caller.
while (stackOffset < pStackTrace.Fra meCount)
{
// Collect information from the call stack.
Type speakerObject = this.GetType(). BaseType;
StackFrame stackFrame = pStackTrace.Get Frame(stackOffs et);
MethodBase stackMethod = stackFrame.GetM ethod();
// Evaluate if the method belongq to the abstract object speaker.
if (stackMethod.De claringType == speakerObject)
{
stackOffset++;
continue;
}
// Evaluate if the method belongq to a specific object speaker.
if (stackMethod.De claringType.Bas eType == speakerObject)
{
stackOffset++;
continue;
}
// The method does not belong to an object speaker.
break;
}
// Provide the stack offset of the caller method.
return(stackOff set);
}
}
}
Please let me know if you need more info.
Kurt
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Kurt Biesemans <Ku************ @KubiSoft.biz> wrote: I have a line code : StackTrace stackTrace = new StackTrace(fals e);
When I run the project in debug, the application keeps hanging on this
line.
My Environment:
Windows 2003 Server Standard SP1
Visual Studio 2003 SP1
Any help is welcome
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too