Hi,
In the following class
Xtensive.Storage.Disconnected.DisconnectedSessionHandler
In the GetReferencesTo method, the 'item' can become null in the first foreach. DO crashes with 'null reference' exception when trying to access the 'item.Entity'.
Regards
Paul Sinnema
Diartis AG
/// <inheritdoc/>
public override IEnumerable<ReferenceInfo> GetReferencesTo(Entity target, AssociationInfo association)
{
switch (association.Multiplicity) {
case Multiplicity.ManyToOne:
case Multiplicity.ZeroToOne:
case Multiplicity.ZeroToMany:
case Multiplicity.ManyToMany:
Session.Persist();
var list = new List<ReferenceInfo>();
var state = disconnectedState.GetEntityState(target.Key);
foreach (var reference in state.GetReferences(association.OwnerField)) {
var item = FetchEntityState(reference.Key);
list.Add(new ReferenceInfo(item.Entity, target, association));
}
return list;
case Multiplicity.OneToOne:
case Multiplicity.OneToMany:
var key = target.GetReferenceKey(association.Reversed.OwnerField);
if (key!=null)
return EnumerableUtils.One(new ReferenceInfo(FetchEntityState(key).Entity, target, association));
break;
}
throw new ArgumentException("association.Multiplicity");
}
Updated at 30.07.2010 11:38:36
Just to illustrate what's going wrong.
Test 'Diartis.KLIB.KLIBUnitTests.VMMaintenanceStateMachineTest.PersonTest' failed: System.NullReferenceException : Object reference not set to an instance of an object.
at Xtensive.Storage.Disconnected.DisconnectedSessionHandler.GetReferencesTo(Entity target, AssociationInfo association)
at Xtensive.Storage.ReferenceFinder.GetReferencesTo(Entity target, AssociationInfo association)
at Xtensive.Storage.ReferentialIntegrity.RemovalProcessor.ProcessItems(IList`1 entities)
at Xtensive.Storage.ReferentialIntegrity.RemovalProcessor.Remove(IEnumerable`1 entities)
at Xtensive.Storage.Entity.Remove()
AbstractEntity.cs(570,0): at Diartis.KLIB.Model.AbstractEntity.OnDelete()
Generated\Contact.Generated.cs(923,0): at Diartis.KLIB.Model.Contact.OnDelete()
Generated\Person.Generated.cs(2109,0): at Diartis.KLIB.Model.Person.OnDelete()
AbstractEntity.cs(556,0): at Diartis.KLIB.Model.AbstractEntity.Delete()
VMEntity.cs(522,0): at Diartis.KLIB.KLIBViewModel.VMEntity.Delete()
StateMachines\VMMaintenanceStateMachine.cs(370,0): at Diartis.KLIB.KLIBViewModel.StateMachines.VMMaintenanceStateMachine`1.Cancel()
VMMaintenanceStateMachineTest.cs(95,0): at Diartis.KLIB.KLIBUnitTests.VMMaintenanceStateMachineTest.PersonTest()
Updated at 31.07.2010 23:57:27
Hi Alex,
It's right here:
var item = FetchEntityState(reference.Key);
list.Add(new ReferenceInfo(item.Entity, target, association));
I've debugged the code into the FetchEntityState(). That's where it becomes null.
Regards
Paul
Updated at 07.08.2010 10:54:33
What's the status of this one?
This thread was imported from our support forum. The original discussion may contain more detailed answer.
asked
Jul 30 '10 at 10:41
Paul Sinnema
261●88●88●96
Could you try to reproduce it with our .PDBs to get info about line number?
No any updates yet, but I'll contact you about this soon - likely, I'll need more details.
Up. Will be investigated shortly.
Just fixed this.