Object reference - GetEntityFieldPropertyDescriptors

Posts   
 
    
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 12-Dec-2007 17:41:54   

Not an error I've had before. Any hints where to start looking for this?

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.FieldUtilities.GetEntityFieldPropertyDescriptors(IEntity2 dummyInstance, List1& instanceProperties, Dictionary2& namesAdded) +53 SD.LLBLGen.Pro.ORMSupportClasses.EntityView21.GetEntityFieldPropertyDescriptors(IEntityCore dummyInstance, List1& instanceProperties, Dictionary2& namesAdded) +47 SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase1.GetPropertyDescriptors(IEntityCore dummyInstance, PropertyDescriptor[] listAccessors) +220 SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.GetItemProperties(PropertyDescriptor[] listAccessors) +390 Telerik.WebControls.GridResolveEnumerable.GetItemProperties(Object source) +70 Telerik.WebControls.GridResolveEnumerable.ParseProperties() +53 Telerik.WebControls.GridResolveEnumerable.Initialize() +10 Telerik.WebControls.GridResolveEnumerable.EnsureInitialized() +17 Telerik.WebControls.GridEnumerableFromDataView..ctor(IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +146 Telerik.WebControls.GridDataSourceHelper.CreateGridEnumerable(IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +126 Telerik.WebControls.GridDataSourceHelper.GetResolvedDataSource(Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +92 Telerik.WebControls.GridTableView.get_ResolvedDataSource() +233 Telerik.WebControls.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +34 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 Telerik.WebControls.GridTableView.PerformSelect() +4 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 Telerik.WebControls.GridTableView.DataBind() +343 Telerik.WebControls.RadGrid.DataBind() +77 Telerik.WebControls.RadGrid.AutoDataBind(GridRebindReason rebindReason) +132 Telerik.WebControls.RadGrid.OnLoad(EventArgs e) +162 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Dec-2007 04:00:03   

Any clues on when this started to happen or steps to reproduce it?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 13-Dec-2007 11:10:31   

Also information about which version you're using, build nr of the runtime lib etc. would be great.

Frans Bouma | Lead developer LLBLGen Pro
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 13-Dec-2007 13:16:51   

I'm using v2.5.

I happens binding an entity collection to a grid. I think it is something to in a partial class property.

I just wondered if you had any hints if you had seen it before... Reproducing the situation is a bit difficult without the full project.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 13-Dec-2007 15:15:34   

Please provide more info as described here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725

Unfortunatly we haven't seen this before, so it would be much helpful if you can help us re-produce it.

Also if you want to attach sensetive code, you may open a new thread in the HelpDesk Forum. No one except the support team and the thread owner can access your questions.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 14-Dec-2007 11:16:50   

Please use the ormsupportclasses debug build dll in the runtime lib folder (with the pdb). You can simply drop the dll in the bin folder of the app and re-run it. you'll then see line numbers in the stacktrace and we can check which line gives the problem and from there trace back simple_smile

Frans Bouma | Lead developer LLBLGen Pro
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 21-Dec-2007 13:16:59   

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.FieldUtilities.GetEntityFieldPropertyDescriptors(IEntity2 dummyInstance, List1& instanceProperties, Dictionary2& namesAdded) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.5 .NET 2.x\ORMSupportClasses\UtilityClasses.cs:870 SD.LLBLGen.Pro.ORMSupportClasses.EntityView21.GetEntityFieldPropertyDescriptors(IEntityCore dummyInstance, List1& instanceProperties, Dictionary2& namesAdded) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.5 .NET 2.x\ORMSupportClasses\EntityView2.cs:289 SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase1.GetPropertyDescriptors(IEntityCore dummyInstance, PropertyDescriptor[] listAccessors) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.5 .NET 2.x\ORMSupportClasses\EntityViewBase.cs:344 SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.GetItemProperties(PropertyDescriptor[] listAccessors) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.5 .NET 2.x\ORMSupportClasses\EntityViewBase.cs:317 Telerik.WebControls.GridResolveEnumerable.GetItemProperties(Object source) +70 Telerik.WebControls.GridResolveEnumerable.ParseProperties() +53 Telerik.WebControls.GridResolveEnumerable.Initialize() +10 Telerik.WebControls.GridResolveEnumerable.EnsureInitialized() +17 Telerik.WebControls.GridEnumerableFromDataView..ctor(IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +146 Telerik.WebControls.GridDataSourceHelper.CreateGridEnumerable(IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +126 Telerik.WebControls.GridDataSourceHelper.GetResolvedDataSource(Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +92 Telerik.WebControls.GridTableView.get_ResolvedDataSource() +233 Telerik.WebControls.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +34 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 Telerik.WebControls.GridTableView.PerformSelect() +4 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 Telerik.WebControls.GridTableView.DataBind() +343 Telerik.WebControls.RadGrid.DataBind() +77 Telerik.WebControls.RadGrid.AutoDataBind(GridRebindReason rebindReason) +132 Telerik.WebControls.RadGrid.OnLoad(EventArgs e) +162 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 21-Dec-2007 14:45:21   

Please provide the LLBLGen Pro runtime library version as described here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725

And please post the code snippet, you used which produced this exception.

simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 21-Dec-2007 16:12:19   

v2.5 24th sept

The line that causes it is the DataBind:

EntityCollection collection = GetBasket(.....); GridView1.DataSource = collection; GridView1.DataBind();

Posts: 254
Joined: 16-Nov-2006
# Posted on: 22-Dec-2007 23:01:03   

Hi Simon

I don't fully understand why Frans has suggested to use a debug build as the line nos here only indicate the line no where the method is located, they don't tell you where in the method the null reference was caused.

However if this is consistently reproducable on your server, it would be much quicker if you could debug and set the debugger to break on a CLR NullReferenceException. If you build against the source runtime libraries you can determine which line in UtilityClasses causes the exception. We can then look into this in more detail.

Of course if this isn't possible e.g. because it's only reproducible in a production environment then well have to look at another approach.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 23-Dec-2007 10:59:43   

MattAdamson wrote:

Hi Simon

I don't fully understand why Frans has suggested to use a debug build as the line nos here only indicate the line no where the method is located, they don't tell you where in the method the null reference was caused.

No, the linenumbers will tell at which line INSIDE the last method the code crashed. That's essential. His stacktrace shows line 870 in utilityclasses.cs. As he uses the build of september 24th, I then go back to the state of that file at september 24th in SVN, and check which line it is. That's this line: foreach( IEntityField2 currentField in dummyInstance.Fields )

As the previous line is: PropertyDescriptorCollection realPropertyDescriptors = TypeDescriptor.GetProperties(dummyInstance.GetType());

it means that dummyInstance isn't null, as it would otherwise crash on that previous line. This only means that Fields is null. simple_smile

This is either a factory problem, or a problem with threading where entity creation is apparently done in code which is ran by multiple threads at once. I think it's the former.

Simon, Do you have any entity with 0 fields?

The issue occurs by calling ITypedList.GetItemProperties on the view (default view) of the bound collection so the grid can obtain the columns to show. This is done by creating a dummy instance using the factory of the collection and obtain the fields of that dummy. Apparently that dummy doesn't have any fields in such a way that the Fields object isnull, not an empty object, which is weird.

Btw, you're running a rather old build of the runtime. We've had some patch releases after september 24th.

Frans Bouma | Lead developer LLBLGen Pro
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 27-Dec-2007 18:52:21   

I have found what the problem was for this.

My custom factory class is using a custom constructor for the entity in its partial class. Adding this line to the end of the constructor seems to have solved the problem: InitClassEmpty(null, CreateFields());