- Home /
Can't retrieve stack information from a dll
I like to print stack info (file name, line in file) along with messages when logging debug messages :
... StackTrace stacktrace = new StackTrace(true); StackFrame stackframe = stacktrace.GetFrame(0);
string currentFile = stackframe.GetFileName(); int currentLine = stackframe.GetFileLineNumber();
Debug.Log("My debug msg" + "in " currentFile + " @"+currentLine); ...
However, I can't retrieve such info from a dll used in a Unity project (line is always 0 and no file name is retrieved). This only works with scripts that are directly included in the project.
This issue makes it very hard to debug my application... Any ideas?
From what I understand, Debug.Log does tell you what object/method the message originates from.
The thing is, to keep things manageable, I use an external logging application (Sentinel) which listens to UDP messages sent from my DLLs. That way, I can easily filter/highlight messages I'm interested in.
However, stack information can't be retrieved when such a DLL is used in the context of a Unity application :( It works perfectly when I use my DLLs from a C# executable though...
Oh, I see - you're not actually Debug.Log()ing the data, but handing it to a UDP emitter ins$$anonymous$$d?
Does it still work with plain C# applications that are built and run with $$anonymous$$ono, rather than $$anonymous$$icrosoft's CLR?
Your answer
![](https://koobas.hobune.stream/wayback/20220613124310im_/https://answers.unity.com/themes/thub/images/avi.jpg)