473,379 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Stacktrace constructor hangs

Hello,

I have a line code : StackTrace stackTrace = new StackTrace(false);
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

Kurt Biesemans
Nov 17 '05 #1
3 1926
Kurt Biesemans <Ku************@KubiSoft.biz> wrote:
I have a line code : StackTrace stackTrace = new StackTrace(false);
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.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
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.WriteLine("BEFORE CALL TO PROCESSING");

processingClass.CreateStackTrace();

Console.WriteLine("AFTER CALL TO PROCESSING");

}

}

}

SECOND CLASS: Name = Processing.cs

using System;

using System.Reflection;

using System.Diagnostics;

namespace StackTraceTest

{

public class Processing

{

public Processing()

{

}

public void CreateStackTrace()

{

Console.WriteLine("BEFORE CREATION OF STACKTRACE");

StackTrace stackTrace = new StackTrace(false);

Console.WriteLine("AFTER CREATION OF STACKTRACE");

int stackOffset = GetCallerStackOffset(stackTrace);

StackFrame stackFrame = stackTrace.GetFrame(stackOffset);

int callerOffset = stackTrace.FrameCount - stackOffset;

}

private int GetCallerStackOffset(StackTrace pStackTrace)

{

int stackOffset = 0;

// Lookup for the method of the object speaker caller.

while (stackOffset < pStackTrace.FrameCount)

{

// Collect information from the call stack.

Type speakerObject = this.GetType().BaseType;

StackFrame stackFrame = pStackTrace.GetFrame(stackOffset);

MethodBase stackMethod = stackFrame.GetMethod();

// Evaluate if the method belongq to the abstract object speaker.

if (stackMethod.DeclaringType == speakerObject)

{

stackOffset++;

continue;

}

// Evaluate if the method belongq to a specific object speaker.

if (stackMethod.DeclaringType.BaseType == speakerObject)

{

stackOffset++;

continue;

}

// The method does not belong to an object speaker.

break;

}

// Provide the stack offset of the caller method.

return(stackOffset);

}

}

}

Please let me know if you need more info.

Kurt

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Kurt Biesemans <Ku************@KubiSoft.biz> wrote:
I have a line code : StackTrace stackTrace = new StackTrace(false);
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.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3
Kurt Biesemans <Ku************@KubiSoft.biz> wrote:
I made a simple application that executes the specific line that hangs.


<snip>

Hmm... and it hangs on your box? It works fine on mine, I'm afraid...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robert Phillips | last post by:
I can successfully place a StackTrace object a MSMQ queue, but when trying to retrieve it, the call to Message.Body hangs and doesn't return. Strings and my custom objects work fine. I assumed...
0
by: MTK | last post by:
My application hangs at times when creating an instance of the Systems.Diagnostics.Stacktrace. StackTrace st = new StackTrace(true); This doesnt happen all the time, just once in many days. ...
4
by: Barry Mossman | last post by:
Hi, I am throwing an exception derived from ApplicationException as follows catch (Exception ex) { throw new MyException("message", ex); } My exception's constructor is: public...
2
by: norvinl | last post by:
Hi, I have a textbox on a form. When I assign a string to the .Text property while in my form's constructor, the program just hangs indefinitely. Alternatively, if I assign the string to the...
4
by: Tom Shelton | last post by:
Problem: XmlTextReader Constructor hangs until underlying socket closes when passed a NetworkStream. Example: Dim reader As New XmlTextReader (New NetworkStream(s, False)) I can...
2
by: Adam Clauss | last post by:
There is a StackTrace constructor that can take a target thread. This requires that the target thread be Suspended. However, the Suspend() method of Thread is now deprecated. Is there an...
7
by: Morgan Cheng | last post by:
In the book *Programming C#* 4th editionby Jesse Liberty, it reads "Actually, the CLR guarantees to start running the static constructor before anything else is done with your class. However, it...
3
by: rani.yaroshinski | last post by:
Hi all, The Stacktrace class (system.diagnostic) in CLR 2.0 (Framework 2.0), still offers a constructor to allow showing the stack-trace of another thread. However, the usage involves suspending...
1
by: lesani | last post by:
hi, i want to find out stacktrace of a thread that is only have its thread id (which have created in vc++ project), i can find processthread by searching in ids of...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.