mini-profiler nullreferenceexception

时间:2011-11-14 21:27:36

标签: mvc-mini-profiler

当我正在运行的存储过程执行mini-profiler时抛出一个空引用并导致我的应用程序停止。在这种情况下,SP不会返回任何内容。

这是stacktrace:

   at MvcMiniProfiler.MiniProfiler.AddSqlTiming(SqlTiming stats) in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\MiniProfiler.cs:line 274
   at MvcMiniProfiler.SqlTiming..ctor(DbCommand command, ExecuteType type, MiniProfiler profiler) in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\SqlTiming.cs:line 137
   at MvcMiniProfiler.SqlProfiler.ExecuteStartImpl(DbCommand command, ExecuteType type) in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\SqlProfiler.cs:line 39
   at MvcMiniProfiler.SqlProfilerExtensions.ExecuteStart(SqlProfiler sqlProfiler, DbCommand command, ExecuteType type) in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\SqlProfiler.cs:line 93
   at MvcMiniProfiler.MiniProfiler.MvcMiniProfiler.Data.IDbProfiler.ExecuteStart(DbCommand profiledDbCommand, ExecuteType executeType) in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\MiniProfiler.IDbProfiler.cs:line 14
   at MvcMiniProfiler.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\Data\ProfiledDbCommand.cs:line 158
   at System.Data.Common.DbCommand.ExecuteReader()
   at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
   at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   at System.Data.Linq.DataContext.ExecuteMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters)
   at NetINFO.NetINFODataContext.usp_SRM_GetPlansByType(Nullable`1 sRM_ID, Nullable`1 sRM_PlanTypeID) in C:\Code\netinfo\NetInfo.Web\App_Data\NetINFO.designer.cs:line 1949
   at NetINFO.NetCMG.SRM.GetSRMPlans(Int32 pPlanType) in C:\Code\netinfo\NetInfo.Web\pages\NetCMG\classes\SRM.cs:line 673
   at NetINFO.NetCMG.SRM.Validate() in C:\Code\netinfo\NetInfo.Web\pages\NetCMG\classes\SRM.cs:line 540
   at NetCMG.Controls.TicketErrorsCtl.ValidateTicket(SRM Ticket) in C:\Code\netinfo\NetInfo.Web\pages\NetCMG\Controls\TicketErrorsCtl.ascx.cs:line 29
   at NetCMG.Controls.TicketErrorsCtl.Page_Load(Object sender, EventArgs e) in C:\Code\netinfo\NetInfo.Web\pages\NetCMG\Controls\TicketErrorsCtl.ascx.cs:line 16
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

2 个答案:

答案 0 :(得分:3)

我终于找到了上述问题的解决方案。错误发生在使用网格的SQL数据源的旧版webforms应用程序上。 sql数据源使用'ProviderName'属性。删除此属性后,一切都开始工作了。

答案 1 :(得分:0)

出现同样的问题:NRE从应用程序开始。发生例外at MvcMiniProfiler.MiniProfiler.AddSqlTiming(SqlTiming stats)

问题原因:Application_AuthenticateRequest()中的数据库调用

问题解决方案:MiniProfiler.Start();已移至Application_AuthenticateRequest()方法的末尾。