Glimpse EF6:类型' System.NullReferenceException'的第一次机会异常发生在EntityFramework.SqlServer.dll中

时间:2014-04-14 18:14:18

标签: entity-framework glimpse

以下代码抛出了第一次机会异常:

public HttpResponseMessage Get(int id)
{
        try
        {
            var module = _module.ODataQueryable().SingleOrDefault(m => m.ModuleId == id);
            return Request.CreateResponse(HttpStatusCode.Created, module);
        }
        catch (Exception ex)
        {
            Log.ErrorException("Error adding module", ex);
            return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
        }
}

如果我们用一个硬编码的int值替换id变量,例如34,则代码​​运行。

异常的来源是Glimpse.EF6,堆栈跟踪是:

   at Glimpse.EF.AlternateType.GlimpseDbProviderServices.SetDbParameterValue(DbParameter parameter, TypeUsage parameterType, Object value)
   at System.Data.Entity.Core.Common.DbProviderServices.SetParameterValue(DbParameter parameter, TypeUsage parameterType, Object value)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.SyncParameterProperties(EntityParameter entityParameter, DbParameter storeParameter, DbProviderServices storeProviderServices)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.PrepareEntityCommandBeforeExecution(EntityCommand entityCommand)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2[TResult](IEnumerable`1 sequence)
   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
   at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at Denarii.Issuing.Web.ClientPortal.Api.ModuleController.Get(Int32 id) in c:\Projects\Denarii.Issuing\Denarii.Issuing.Web.ClientPortal\Api\ModuleController.cs:line 64

我是否需要调试Glimpse EF6插件?从WinForms应用程序或控制台应用程序调用时,模块服务(_module)可以正常工作。任何帮助非常感谢。

1 个答案:

答案 0 :(得分:0)

您所谈论的问题是一个已知问题,您可以在Glimpse问题列表中找到here

随意添加可能有助于解决问题的其他信息

更新:The issue已由@anthonyv在同时修复