Search code examples
c#uwpstack-framegetmethod

Replace System.Diagnostics.StackFrame.GetMethod in UWP


Porting some code from .NET Framework to UWP, and I'm not sure how to replicate this in a UWP project:

StackFrame frame = new StackFrame(1);
var method = frame.GetMethod();
var names = method.Name.Split('_');
var propertyName = names.Length == 2 ? names[1] : names[0];

Any help?


Solution

  • If you are targetting UWP build minimum version less than 16299, you can't use StackFrame to achieve what you mentioned.

    StackFrame was added later in .Net Standard 2.0 and was not part of the older version of .Net Standard, so in order to use .Net Standard 2.0 you need to update your UWP App minimum build version number to Fall Creators Update 16299.

    Reference Links:

    Github - Implement System.Diagnostics.StackTrace/StackFrame

    .Net Standard 2.0 For UWP