Bug with Disposed Session. How to reproduce:

Create new DO WebApp Create Model with EntitySet, for example:

[Serializable]
[HierarchyRoot]
public class MyEntity : Entity
{
    [HierarchyRoot]
    public class TablePart : Entity
    {
        public TablePart()
            : base()
        {
        }

        public TablePart(Session session)
            : base(session)
        {
        }

        [Field]
        public MyEntity Owner { get; set; }

        [Field]
        [Key]
        public int Id { get; private set; }

        [Field(Length = 100)]
        public string Text { get; set; }

    }

    [Field]
    [Association(PairTo = "Owner")]
    public EntitySet<TablePart> Tp { get; private set; }

    [Field]
    [Key]
    public int Id { get; private set; }

    [Field(Length = 100)]
    public string Text { get; set; }

    public MyEntity()
        : base()
    {
    }

    public MyEntity(Session session)
        : base(session)
    {
    }
}

Create web page with

protected void Page_Load(object sender, EventArgs e)
{
    var session = Xtensive.Orm.Session.Current;
    var myEntity = session.Query.All<MyEntity>().Single();
    CollectionAssert.IsNotEmpty(myEntity.Tp);
}

Open this page and pres F5 several times.

Get exception:

System.ObjectDisposedException was unhandled by user code
  Message=Cannot access a disposed object.
Object name: 'Session is already disposed.'.
  Source=Xtensive.Orm
  ObjectName=Session is already disposed.
  StackTrace:
       at Xtensive.Orm.Session.EnsureNotDisposed() in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Session.cs:line 179
       at Xtensive.Orm.Session.Persist(PersistReason reason) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Session.Persist.cs:line 92
       at Xtensive.Orm.Session.CreateEnumerationContext() in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Session.cs:line 184
       at Xtensive.Orm.Linq.TranslatedQuery`1.Execute(Session session, ParameterContext parameterContext) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Linq\TranslatedQuery{TResult}.cs:line 57
       at Xtensive.Orm.Linq.QueryProvider.Execute[TResult](Expression expression) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Linq\QueryProvider.cs:line 73
       at System.Linq.Queryable.Single[TSource](IQueryable`1 source)
       at Project5.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Work\Project5\Project5\WebForm1.aspx.cs:line 19
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:

asked Jan 23 '12 at 09:17

pil0t's gravatar image

pil0t
207575763


One Answer:

bug in NUnit, fixed: https://bugs.launchpad.net/nunitv2/+bug/920472

answered Jan 24 '12 at 01:20

pil0t's gravatar image

pil0t
207575763

Your answer
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