I
Iain Mcleod
put the following into a console app in .net 2.0, compile it in release mode
and then run it 2 ways:
through visual studio (works as expected)
now double click the console app via windows explorer.
This crashes with a null reference exception because the stacktrace only
contains one frame [it still thinks it's in sub Main()].
This seems to be a problem with release mode and compiler optimisations:
http://www.thescripts.com/forum/thread494282.html[^]
My question:
Is there any SAFE way to get the calling method's methodinfo object?
Thanks in advance
Iain
Module Module1
Sub Main()
TestFunction()
Console.ReadLine()
End Sub
Private Sub TestFunction()
PrintStackTrace()
End Sub
Private Sub PrintStackTrace()
Console.WriteLine(New StackTrace().GetFrame(1).GetMethod().Name)
End Sub
End Module
and then run it 2 ways:
through visual studio (works as expected)
now double click the console app via windows explorer.
This crashes with a null reference exception because the stacktrace only
contains one frame [it still thinks it's in sub Main()].
This seems to be a problem with release mode and compiler optimisations:
http://www.thescripts.com/forum/thread494282.html[^]
My question:
Is there any SAFE way to get the calling method's methodinfo object?
Thanks in advance
Iain
Module Module1
Sub Main()
TestFunction()
Console.ReadLine()
End Sub
Private Sub TestFunction()
PrintStackTrace()
End Sub
Private Sub PrintStackTrace()
Console.WriteLine(New StackTrace().GetFrame(1).GetMethod().Name)
End Sub
End Module