Object reference not set to an instance of an object.

Posts   
 
    
cgray
User
Posts: 62
Joined: 25-Nov-2007
# Posted on: 29-Aug-2009 00:42:42   

Hello, This is with: LLBLBen Pro 2.6 Final, June 6, 2008 Adapter Template Group Visual Studion 2005, version 8.0.50727.762 NET Framework v. 2.0.50727 Sp 1 Oracle 10g database

I am using the same datasource on two different pages. The first page, which has three GridViews filtered by different criteria, works fine. (Each GridView is in a different View as part of a MultiView.) When I set up the LLBLGenProDataSource2 and a GridView on a new page, in a Web Content Form, the project builds but I get the runtime error below. I have tried changing the name of the base data source, changing the ID, and also varying the Entity factory, but still get the error.

I saw a similar problem as of a couple of years ago, but it sounded as if the most recent version had solved this type of error. I'm hoping to have mulitple pages with the same datasource, each filtering for different content.

I have pasted the error message and stack trace below.

Thanks for any suggestions! Carol

Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelectEntityCollection(Int32 pageSize, Int32 pageNumber, DataSourceSelectArguments arguments) +115 SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelect(DataSourceSelectArguments arguments) +334 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69 System.Web.UI.Control.EnsureChildControls() +87 System.Web.UI.Control.PreRenderRecursiveInternal() +50 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Aug-2009 04:16:09   

I'm hoping to have mulitple pages with the same datasource, each filtering for different content.

Please elaborate more. Do you mean you have some LLBLGenDataSource somewhere and you want to use it in multiple pages?

Also please post the relevant aspx code and code behind related to this issue (for example, the declarative aspx of the LLBLGenDataSource, gridview, and PerformSelect method if you are using LivePersistance=false).

David Elizondo | LLBLGen Support Team
cgray
User
Posts: 62
Joined: 25-Nov-2007
# Posted on: 29-Aug-2009 06:33:51   

Yes, exactly. I hope to use the same data source in multiple pages. Is this not a good idea? That is, should I be using the same Adapter Factory, but then giving it a new ID? Or can I reuse the same settings across multiple pages?

I won't be back at work until next Tuesday, where I have all my code, and will post the details then. I would also appreciate any advice on whether or not it is best live persistence. Is it better to set this as "false"? I have been using "session" as the cache setting, but again, am not sure if this is the best way to go.

My goal: to have multiple pages, with a custom filter for each page, returning data from the same source. And for the moment this is a "read only" situation, displaying data based on a database view that has been set as an entity before the code was generated.

Thanks, and I will post more details soon. Carol

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Aug-2009 05:40:40   

cgray wrote:

Yes, exactly. I hope to use the same data source in multiple pages. Is this not a good idea? That is, should I be using the same Adapter Factory, but then giving it a new ID? Or can I reuse the same settings across multiple pages?

You have to use one **LLBLGenProDataSource **per page. This way the controls can found and communicate with the data source.

cgray wrote:

I would also appreciate any advice on whether or not it is best live persistence. Is it better to set this as "false"? I have been using "session" as the cache setting, but again, am not sure if this is the best way to go.

Use LivePersistence=false when you need to perform custom things other than the normal fetch. If you use LivePersistence=false you have to implement the methods to intercept the activity of LLBLGenProDataSource. (read more...).

If you are only filtering and sorting, you can manage this with LivePersistence=true and setting the **FilterToUse **and **SorterToUse **properties of the LLBLGenProDataSource (at Page_Load or at SomeButton_Click).

Regards.

David Elizondo | LLBLGen Support Team
cgray
User
Posts: 62
Joined: 25-Nov-2007
# Posted on: 02-Sep-2009 19:35:48   

Thanks for the clarification and the good link to the documentation. After quite a bit of experimenting, things are working now. I was not able to repeat the "Object reference not set to an instance of an object" error, so am not sure exactly what fixed things. I added additional datasources and carefully checked the ID used. I also removed and readded the references to LLBLGenPro classes, as I was getting errors in the designer about not being able to create the control for the datasource.

Setting LivePersistence to "True" looks like what shoud work best and most easily for me, at least with this basic read only set of views. It is good to know that I can leave that as is.

When the cache was set to the default "ViewState", I frequently got errors about the connection being interrupted while trying to load. With the cache set to "Session" I don't get this error.

Thanks for your assistance! Carol

cgray
User
Posts: 62
Joined: 25-Nov-2007
# Posted on: 03-Sep-2009 21:03:55   

Just a brief update re setting the cache, so that I don't lead anyone astray: That is, ViewState as the cache location is now working fine. It may be that I had a combination of different settings for the cache that caused the problem, but for all my pages ViewState is now working fine as the default location. simple_smile Carol

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Sep-2009 21:31:03   

Thanks for the feedback Carol. Good to know everything is working now simple_smile

David Elizondo | LLBLGen Support Team