I am experiencing some problems, because properties that seem to be correctly initialized throw NullReferenceException when they are accessed.
I am currently using the latest nightly build that was posted on the web site.
Therefore, I point out that my persistent properties are marked [Field], and not [Field(LazyLoad=true)] as suggested by the workaround (for 4.0.5 build) for a previous post entitled "Problem with abstract persistent classes" by Olorin.
Unfortunately, I have not been able to isolate the bug and post some code for reproducing it.
However, I have noticed that the exception stack trace always indicates that the origin of the error is the same :
at Xtensive.Core.Tuples.TupleExtensions.GetFieldStateMap(Tuple target, TupleFieldState requestedState)
Please find hereafter several stacktraces :
Interception de System.NullReferenceException
Message="Object reference not set to an instance of an object."
Source="Xtensive.Core"
StackTrace:
at Xtensive.Core.Tuples.TupleExtensions.GetFieldStateMap(Tuple target, TupleFieldState requestedState)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreateUpdateTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreatePersistTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.Persist(IEnumerable`1 persistActions, Boolean dirty)
at Xtensive.Storage.Providers.SessionHandler.Persist(EntityChangeRegistry registry, Boolean dirtyFlush)
at Xtensive.Storage.Session.Persist(Boolean dirty)
at Xtensive.Storage.Providers.EnumerationContext..ctor()
at Xtensive.Storage.Providers.CompilationContext.CreateEnumerationContext()
at Xtensive.Storage.Rse.Providers.EnumerationScope.Open()
at Xtensive.Storage.Rse.RecordSet.<GetEnumerator>d__4.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Xtensive.Storage.Internals.RecordSetReader.ReadSingleRow(RecordSet source, Key key)
at Xtensive.Storage.Providers.SessionHandler.Execute(FetchTask task, Key key)
at Xtensive.Storage.Providers.SessionHandler.FetchInstance(Key key)
at Xtensive.Storage.Query.SingleOrDefault(Session session, Key key)
at Xtensive.Storage.Query.SingleOrDefault(Key key)
at Xtensive.Storage.Internals.EntityFieldAccessor`1.GetValue(Persistent obj, FieldInfo field)
at Xtensive.Storage.Persistent.GetFieldValue[T](FieldInfo field)
at Xtensive.Storage.Persistent.GetFieldValue[T](String fieldName)
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.get_ProcessedContainer()
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.MoveDocumentsToOutputAndDoneContainers(Document outputDocument, Document inputDocument) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 271
at Test.Pilot.Kernel.Basic.EchoProcessor.ProcessDocument(Document inputDocument) in D:\Perforce\aradus\Projets\Donatello\Pilot.BusinessTools\Debug\EchoProcessor.cs:line 16
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.ProcessAndMove(Document inputDocument, Document documentToProcess) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 202
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.Execute() in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 175
InnerException:
Interception de System.NullReferenceException
Message="Object reference not set to an instance of an object."
Source="Xtensive.Core"
StackTrace:
at Xtensive.Core.Tuples.TupleExtensions.GetFieldStateMap(Tuple target, TupleFieldState requestedState)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreateUpdateTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreatePersistTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.Persist(IEnumerable`1 persistActions, Boolean dirty)
at Xtensive.Storage.Providers.SessionHandler.Persist(EntityChangeRegistry registry, Boolean dirtyFlush)
at Xtensive.Storage.Session.Persist(Boolean dirty)
at Xtensive.Storage.Providers.EnumerationContext..ctor()
at Xtensive.Storage.Providers.CompilationContext.CreateEnumerationContext()
at Xtensive.Storage.Rse.Providers.EnumerationScope.Open()
at Xtensive.Storage.Rse.RecordSet.<GetEnumerator>d__4.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Linq.Materialization.MaterializationHelper.<Materialize>d__8`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Query.<ExecuteSequence>d__b`1.MoveNext()
at Xtensive.Storage.EntitySet`1.LoadState()
at Xtensive.Storage.TransactionalStateContainer`1.get_State()
at Xtensive.Storage.EntitySetBase.Contains(Key key, Nullable`1 state)
at Xtensive.Storage.EntitySetBase.Contains(Entity item)
at Xtensive.Storage.EntitySetBase.Add(Entity item)
at Xtensive.Storage.EntitySet`1.Add(TItem item)
at Test.Pilot.Kernel.ProcessingWorkflowModel.Document.AddHistoryEntry(String what, HistoryEntryVisibility visibility) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\Document.History.cs:line 24
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.ProcessAndMove(Document inputDocument, Document documentToProcess) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 204
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.Execute() in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 175
InnerException:
Interception de System.NullReferenceException
Message="Object reference not set to an instance of an object."
Source="Xtensive.Core"
StackTrace:
at Xtensive.Core.Tuples.TupleExtensions.GetFieldStateMap(Tuple target, TupleFieldState requestedState)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreateUpdateTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreatePersistTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.Persist(IEnumerable`1 persistActions, Boolean dirty)
at Xtensive.Storage.Providers.SessionHandler.Persist(EntityChangeRegistry registry, Boolean dirtyFlush)
at Xtensive.Storage.Session.Persist(Boolean dirty)
at Xtensive.Storage.Providers.EnumerationContext..ctor()
at Xtensive.Storage.Providers.CompilationContext.CreateEnumerationContext()
at Xtensive.Storage.Rse.Providers.EnumerationScope.Open()
at Xtensive.Storage.Rse.RecordSet.<GetEnumerator>d__4.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Linq.Materialization.MaterializationHelper.<Materialize>d__8`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Query.<ExecuteSequence>d__b`1.MoveNext()
at Xtensive.Storage.EntitySet`1.LoadState()
at Xtensive.Storage.TransactionalStateContainer`1.get_State()
at Xtensive.Storage.EntitySetBase.Contains(Key key, Nullable`1 state)
at Xtensive.Storage.EntitySetBase.Contains(Entity item)
at Xtensive.Storage.EntitySetBase.Add(Entity item)
at Xtensive.Storage.Internals.AssociationActionProvider.<.cctor>b__3(AssociationInfo association, IEntity owner, IEntity target)
at Xtensive.Storage.PairIntegrity.SyncContext.ExecuteNextAction()
at Xtensive.Storage.PairIntegrity.SyncManager.Enlist(OperationType type, Entity owner, Entity target, AssociationInfo association)
at Xtensive.Storage.Persistent.SetFieldValue[T](FieldInfo field, T value)
at Xtensive.Storage.Persistent.SetFieldValue[T](String fieldName, T value)
at Test.Pilot.Kernel.ProcessingWorkflowModel.HistoryEntry.set_Owner(Document value)
at Test.Pilot.Kernel.ProcessingWorkflowModel.Document.AddHistoryEntry(String what, HistoryEntryVisibility visibility) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\Document.History.cs:line 24
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.ProcessAndMove(Document inputDocument, Document documentToProcess) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 204
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.Execute() in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 175
InnerException:
L'exception System.NullReferenceException n'a pas été gérée
Message="Object reference not set to an instance of an object."
Source="Xtensive.Core"
StackTrace:
at Xtensive.Core.Tuples.TupleExtensions.GetFieldStateMap(Tuple target, TupleFieldState requestedState)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreateUpdateTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreatePersistTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.Persist(IEnumerable`1 persistActions, Boolean dirty)
at Xtensive.Storage.Providers.SessionHandler.Persist(EntityChangeRegistry registry, Boolean dirtyFlush)
at Xtensive.Storage.Session.Persist(Boolean dirty)
at Xtensive.Storage.Providers.EnumerationContext..ctor()
at Xtensive.Storage.Providers.CompilationContext.CreateEnumerationContext()
at Xtensive.Storage.Rse.Providers.EnumerationScope.Open()
at Xtensive.Storage.Rse.RecordSet.<GetEnumerator>d__4.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Linq.Materialization.MaterializationHelper.<Materialize>d__8`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Query.<ExecuteSequence>d__b`1.MoveNext()
at Xtensive.Storage.EntitySet`1.LoadState()
at Xtensive.Storage.TransactionalStateContainer`1.get_State()
at Xtensive.Storage.EntitySetBase.get_Count()
InnerException:
Is there any other piece of information I can post in order to ease the investigation ?
Would there any Domain or Session options related to lazy loading (if it is relevant) that might be a workaround ?
Kind regards,
Auguste
Updated at 17.09.2009 14:58:31
Here is some more context about the problem.
The bug occurs in a call to AddHistoryEntry method, in the Document class, where Document has a property EntitySet<historyentry> HistoryEntries .
The exception stack trace is the same, whether I used [Field] or [Field(Lazyload=true)] for the property HistoryEntries :
Interception de System.NullReferenceException
Message="Object reference not set to an instance of an object."
Source="Xtensive.Core"
StackTrace:
at Xtensive.Core.Tuples.TupleExtensions.GetFieldStateMap(Tuple target, TupleFieldState requestedState)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreateUpdateTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.CreatePersistTask(PersistAction action)
at Xtensive.Storage.Providers.Sql.SessionHandler.Persist(IEnumerable`1 persistActions, Boolean dirty)
at Xtensive.Storage.Providers.SessionHandler.Persist(EntityChangeRegistry registry, Boolean dirtyFlush)
at Xtensive.Storage.Session.Persist(Boolean dirty)
at Xtensive.Storage.Providers.EnumerationContext..ctor()
at Xtensive.Storage.Providers.CompilationContext.CreateEnumerationContext()
at Xtensive.Storage.Rse.Providers.EnumerationScope.Open()
at Xtensive.Storage.Rse.RecordSet.<GetEnumerator>d__4.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Linq.Materialization.MaterializationHelper.<Materialize>d__8`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.Collections.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.Query.<ExecuteSequence>d__b`1.MoveNext()
at Xtensive.Storage.EntitySet`1.LoadState()
at Xtensive.Storage.TransactionalStateContainer`1.get_State()
at Xtensive.Storage.EntitySetBase.Contains(Key key, Nullable`1 state)
at Xtensive.Storage.EntitySetBase.Contains(Entity item)
at Xtensive.Storage.EntitySetBase.Add(Entity item)
at Xtensive.Storage.EntitySet`1.Add(TItem item)
at Test.Pilot.Kernel.ProcessingWorkflowModel.Document.AddHistoryEntry(String what, HistoryEntryVisibility visibility) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\Document.History.cs:line 25
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.ProcessAndMove(Document inputDocument, Document documentToProcess) in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 204
at Test.Pilot.Kernel.ProcessingWorkflowModel.QueueProcessor.Execute() in D:\Perforce\aradus\Projets\Donatello\Pilot.Kernel.ProcessingWorkflowModel\QueueProcessor.cs:line 175
InnerException:
Here is the related part of the Document class :
[HierarchyRoot]
public partial class Document : Entity
{
[Field, Key]
public long Id { get; private set; }
[Field, Association(PairTo = "Owner", OnOwnerRemove = OnRemoveAction.Clear)]
public EntitySet<HistoryEntry> HistoryEntries { get; private set; }
public void AddHistoryEntry(string what, HistoryEntryVisibility visibility)
{
HistoryEntry historyEntry = new HistoryEntry { What = what, Visibility = visibility, When = DateTime.Now};
HistoryEntries.Add(historyEntry);
log.DebugFormat("History entry added for {0}. {1}What : {2}", ToString(), Environment.NewLine, what);
}
}
Here is the HistoryEntry class :
[HierarchyRoot]
public class HistoryEntry : Entity
{
[Field, Key]
public long Id { get; private set; }
public const HistoryEntryVisibility VisibilityForAll = HistoryEntryVisibility.EndUser | HistoryEntryVisibility.AdministratorUser | HistoryEntryVisibility.Debugger;
[Field]
public string What { get; set; }
[Field]
public DateTime When { get; set; }
[Field]
public HistoryEntryVisibility Visibility { get; set; }
[Field]
public Document Owner { get; set; }
}
Kind regards,
Auguste
Updated at 21.09.2009 10:07:19
Could you please specify the File version & File creation date of Xtensive.Storage.dll? This could help us to quickly revert code base exactly to your revision and run the tests.
.
Hello Dmitri,
The dll Xtensive.Storage has a modification date of 05 september 2009, 04:41 (AM).
It is the last nightly build that I could find the DataObjects web site.
Right click on the dll indicates a file version 1.0.0.0 (which does not seem very informative)
Hope that helps.
Best regards.
Auguste
This thread was imported from our support forum. The original discussion may contain more detailed answer.
We'll try to isolate the issue tomorrow. If it will be fixed, I'll send you the latest nightly build on this weekend (we're updating Xtensive.Core now as well, so likely we'll need some time to merge all the changes).
Forgot to add - the report seems very comprehensive. Normally stack trace & exception is enough to locate the issue.