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看一下具体出错在哪一行

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办