chgsh_2008 2014-10-15 03:06 采纳率: 0%
浏览 1872

请问下大家有没遇到EF调用GetValidationErrors时出错

请问下大家有没遇到EF调用GetValidationErrors时出错,我知道报错是说未将对象设置为引用对象,但我不明白为什么调用GetValidationErrors时里面报错。错误代码如下:
error message:Object reference not set to an instance of an object., the UniqueReference value is :1334241M01. We will move this file.]
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Core.Objects.EntityEntry.DetectChangesInProperty(Int32 ordinal, Boolean detectOnlyComplexProperties, Boolean detectOnly)
at System.Data.Entity.Core.Objects.EntityEntry.DetectChangesInProperties(Boolean detectOnlyComplexProperties)
at System.Data.Entity.Core.Objects.ObjectStateManager.DetectChangesInScalarAndComplexProperties(IList1 entries)
at System.Data.Entity.Core.Objects.ObjectStateManager.DetectChanges()
at System.Data.Entity.Core.Objects.ObjectContext.DetectChanges()
at System.Data.Entity.Internal.InternalContext.DetectChanges(Boolean force)
at System.Data.Entity.Internal.InternalContext.GetStateEntries(Func
2 predicate)
at System.Data.Entity.Internal.InternalContext.GetStateEntries()
at System.Data.Entity.Infrastructure.DbChangeTracker.Entries()
at System.Data.Entity.DbContext.GetValidationErrors()
at Ligentia.DataTool.ClientLibraries.OfficeWorks.JobImportShipmentData.getDbError(Ligentix4Entities L4Entities)。
其中getDbError是我自己写的方法。其余都是调用微软的EFContext.GetValidationErrors()时报错了。但在调用GetValidationErrors()方法前,我有判断调用的对象不是为空了,如:
if (l4Entities != null)
{
IEnumerable validationResults =l4Context.GetValidationErrors();
}
请教大家帮帮忙看下为什么啊?谢谢大家

  • 写回答

1条回答 默认 最新

  • q107770540 2014-12-08 02:53
    关注

    System.NullReferenceException: Object reference not set to an instance of an object.

    空引用了,debug看一下具体出错在哪一行

    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站