This is a migrated thread and some comments may be shown as answers.

Null Database Object in my Scope Provider

3 Answers 58 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brendan Enrick
Top achievements
Rank 1
Brendan Enrick asked on 29 Sep 2009, 12:30 PM
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

3 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 29 Sep 2009, 02:08 PM
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.
0
Brendan Enrick
Top achievements
Rank 1
answered on 30 Sep 2009, 03:38 PM
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?
0
Thomas
Telerik team
answered on 01 Oct 2009, 10:10 AM
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.
Tags
Getting Started
Asked by
Brendan Enrick
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Brendan Enrick
Top achievements
Rank 1
Share this question
or