Null Database Object in my Scope Provider

4 posts, 0 answers
  1. Brendan Enrick
    Brendan Enrick avatar
    28 posts
    Member since:
    Jul 2009

    Posted 29 Sep 2009 Link to this post

    Hello,

    In my ScopeProvider class when I call the GetNewObjectScope() method the Database object it uses is sometimes null and I get a null reference exception.

    static public IObjectScope GetNewObjectScope() 
        Database db = Database(); 
     
        IObjectScope newScope = db.GetObjectScope(); // Null Reference here 
        return newScope; 

    Thanks for the help,
    Brendan
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 29 Sep 2009 Link to this post

    Hello Brendan Enrick,

    certainly the database could not be opened in this circumstance. Are you using multiple threads so that another one is calling db.Dispose() incorrectly? What else are the conditions to produce this behavior?

    All the best,
    Thomas
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Brendan Enrick
    Brendan Enrick avatar
    28 posts
    Member since:
    Jul 2009

    Posted 30 Sep 2009 Link to this post

    It is a web site so there are multiple threads. I am not directly calling Dispose on the db object, but I do dispose of the ObjectScope. Does that call dispose on the db object?
  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 01 Oct 2009 Link to this post

    Hello Brendan Enrick,

    that is strange then, especially your statement that it is happening _sometimes_. We need to find out why only sometimes - can that be correlated to a significant other event? A more complete stack trace would also be good to find the reason why.

    Kind regards,
    Thomas
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top