询问者
WP8.1开发过程中,如何打印详细日志,包括行号,类名,方法名等信息,以便能快速定位到错位位置?

问题
-
WP8.1开发过程中,如何打印详细日志,包括行号,类名,方法名等信息,以便能快速定位到错错误位置?
- 已编辑 Airforce_jie 2016年5月6日 2:59
全部回复
-
这里有答案
For Windows Store apps in .Net languages you would get the StackTrace from an exception.
For Windows Phone 8 you can use System.Diagnostics.Stacktrace().
专注于.NET MIS开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms
- 已建议为答案 Xavier Xie-MSFTModerator 2016年5月25日 7:57
-
private void WriteLog() { StackTrace st = new StackTrace(true); StackFrame[] sfs = st.GetFrames(); if (sfs.Length >= 2) { StackFrame sf = sfs[1]; Console.WriteLine(" File: {0}; Method: {1};Line: {2};Column: {3}", sf.GetFileName(), sf.GetMethod().Name, sf.GetFileLineNumber(), sf.GetFileColumnNumber()); } }
这是wpf的,在wp上可能需要改动
- 已编辑 umi-aoi 2016年5月18日 3:12