The code bellow throws NullReferenceException at leaf.Dummy.Add(new Leaf());

[HierarchyRoot]
class Base : Entity
{
  public EntitySet<Base> Dummy { get; private set; }
}

class Leaf : Base 
{
 ...
}

void Main() 
{
  build domain
  using (open session)
  {
    using (open transaction)
    {
      Leaf leaf = new Leaf();
      leaf.Dummy.Add(new Leaf()); // CAUSES NullReferenceException (see
bellow for excpetion details)
    }
  }
}

Note that if the Base.Dummy property is moved down to the Leaf, leaf.Dummy.Add will work correctly.

Exception details:

System.NullReferenceException
   at Xtensive.Storage.EntitySetBase.Contains(Key key)
   at Xtensive.Storage.EntitySetBase.Contains(Entity item)
   at Xtensive.Storage.EntitySetBase.Add(Entity item, Boolean notify)
   at Xtensive.Storage.EntitySet`1.Add(TItem item)
   at BoldBrick.CRM.DataServices.AccountServices.CreateOpenIDAccount(String openID) in C:\svn\www\workspaces\secondlife\BoldBrick.CRM\DataServices\AccountServices.cs:line 27
   at BoldBrick.CRM.API.AccountManagement.CreateOpenIDAccount(OpenIDAccountInfo accountInfo) in C:\svn\www\workspaces\secondlife\BoldBrick.CRM\API\AccountManagement.cs:line 45
   at BoldBrick.CRM.FillerConsole.Main() in C:\svn\www\workspaces\secondlife\BoldBrick.CRM\FillerConsole.cs:line 36
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

http://code.google.com/p/dataobjectsdotnet/issues/detail?id=284

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by lopata.

asked Jul 12 '09 at 08:30

Editor's gravatar image

Editor
46154156157

Accepted - thanks for adding the issue into our bug tracker.

We'll try to fix it on Monday\Tuesday. The fix will be available in nightly builds.

(Jul 12 '09 at 08:30) Alex Yakunin Alex%20Yakunin's gravatar image

Hello lopata,

Thanks for the bug report.

Fixed. See nightly build.

(Jul 12 '09 at 08:30) Dmitri Maximov Dmitri%20Maximov's gravatar image
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA