locked
Which class instead of StackTrace in windows 8 metro app? RRS feed

  • Question

  • I wanna to use StackTrace to get the function callstack, but I cannot find any class to be used.  In .Net 4.0, we have a class StackTrace can be used, Which class instead of it in windows 8 metro app? 
    Saturday, April 7, 2012 10:23 AM

Answers

  • C++/Cx apps are not managed code and do not use the .Net framework.

    There is no easy way to get a stack trace for native code. Managed code includes markers which make it much easier to get a managed stack trace, but since the Windows Runtime classes are all native code the StackTrace function couldn't see them even if it were available to a managed Metro style app.

    Unmanaged Desktop apps can use StackWalk64() from the Debug Help library, but this is not available to Metro style apps.

    --Rob

    Monday, April 9, 2012 6:59 PM
    Moderator

All replies

  • Hello,

    Metro style apps do not support all the .NET APIs. You can check the supported API in System.Diagnostics Namespaces.
    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441592(v=vs.110).aspx

    Maybe we need find another way to use stack trace in metro style app.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 9, 2012 9:04 AM
  • C++/Cx apps are not managed code and do not use the .Net framework.

    There is no easy way to get a stack trace for native code. Managed code includes markers which make it much easier to get a managed stack trace, but since the Windows Runtime classes are all native code the StackTrace function couldn't see them even if it were available to a managed Metro style app.

    Unmanaged Desktop apps can use StackWalk64() from the Debug Help library, but this is not available to Metro style apps.

    --Rob

    Monday, April 9, 2012 6:59 PM
    Moderator
  • A way to perform a stack walk in metro would be very handy. In fact, StackWalk64 was the first time I realized there are a bunch of APIs not available in Metro. My "std::string GetStackTrace(int removeStackEntries)" method is still empty. :/
    Monday, April 9, 2012 7:04 PM
  • Can you describe a use case scenario where you would find this useful in a Metro style app? Is this something you were just looking to utilize during your development phase?

    David Lamb

    Wednesday, April 11, 2012 3:27 PM
    Moderator
  • such as log message,  the log message only a debug string in code, but I wanna to add some more information like which 

    class, which method, invoke the log message call. And according to the namespace of the caller class, we can let he 

    log should show or not, etc.
    Thursday, April 12, 2012 5:33 AM
  • I can think of several reasons.  The fact that we are promoting Windows 8 Metro by developing Applications for it hasn't changed the reasons why we would want to get a stack trace.

    1. Crash Reporting is much more usefull when we can capture the call stack.

    2. Instrumentation and profiling gets much easier when we aren't using breakpoints and stop watches.

    3. Branch analysis.

    4. Becuase I'm writing a tool that can tell you where you have data contengencies in your multi threaded Windows 8 Metro Application, so you can fix those issues and make it look like Microsoft has done all of the hard work.

    5. Etc. Etc. Etc.

    BTW: Anyone who needs a reason for looking at the stack has really never worked on a serious project.

    Friday, April 13, 2012 3:30 PM
  • Ditto what Dan said (btw). Use case for stack trace? Instrumentation.

    Tuesday, July 17, 2012 6:18 AM