VisualStudio代码调试输出跟踪
Posted 未将对象引用设置到对象的实例
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VisualStudio代码调试输出跟踪相关的知识,希望对你有一定的参考价值。
class EFIntercepterLogging : DbCommandInterceptor { private readonly Stopwatch _stopwatch = new Stopwatch(); public override void ScalarExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext<object> interceptionContext) { base.ScalarExecuting(command, interceptionContext); _stopwatch.Restart(); } public override void ScalarExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext<object> interceptionContext) { _stopwatch.Stop(); if (interceptionContext.Exception != null) { Trace.TraceError ("Exception:{1} \r\n --> Error executing command: {0}", command.CommandText, interceptionContext.Exception.ToString()); } else { Trace.TraceInformation("\r\n执行时间:{0} 毫秒\r\n-->ScalarExecuted.Command:{1}\r\n", _stopwatch.ElapsedMilliseconds, command.CommandText); } base.ScalarExecuted(command, interceptionContext); } }
以上是关于VisualStudio代码调试输出跟踪的主要内容,如果未能解决你的问题,请参考以下文章