Problem Creating an EntityPropertyDescriptor

Posts   
 
    
Fred avatar
Fred
User
Posts: 21
Joined: 04-Mar-2005
# Posted on: 25-Jan-2007 22:39:01   

Hello,

please see if you can help with the problem below. I'm attempting to create an EntityPropertyDescriptor and getting a null reference exception. Help will be much appreciated.

Fred

LLBLGen Pro version/buildnumber: 1.0.2004.1 Final Runtime library version: v1.1.4322 (updated... sorry about previous error here) Template group: self-servicing .Net version: 1.1 Database type: Sql Server 2000

The PageTypeEnum parameter is defined like so: public enum PageTypeEnum : int { Home = 62 , About = 63 // etc }

The constant ITEM_NOT_IN_COLLECTION is -1.

The "Page" table of the database is scripted as follows: CREATE TABLE [dbo].[Page] ( [PageID] [int] IDENTITY (1, 1) NOT NULL , [PageTypeLID] [int] NOT NULL , [SiteID] [int] NOT NULL , [IsDisplayed] [bit] NOT NULL , [IsComplete] [bit] NOT NULL ) ON [PRIMARY] GO

Hierarchy: A PracticeEntity has a SiteCollection.
A SiteEntity has a PageCollection.
A PageEntity has a ContentCollection.

The routine throwing the error is attempting to return the requested pageEntity based on its PageTypeLID, which corresponds to the PageTypeEnum. Here is the code for that routine.

public PageEntity GetPageEntity(PageTypeEnum pt) 
{
    EntityPropertyDescriptor ptLID = new 
        EntityPropertyDescriptor(EntityFieldFactory.Create(PageFieldIndex.PageTypeLID), typeof(PageEntity));

    int idx = ActiveSite.PageCollection.Find(ptLID, (int)pt);
    if (idx != BHCS.HTPN.API.Constants.ITEM_NOT_IN_COLLECTION) 
    {
        return ActiveSite.PageCollection[idx];
    }
    return null;
}

The problem occurrs in the first line, creating the property descriptor. Below is the exception data from that. At the end of DataAccess.Create(PageFieldIndex fieldIndex) it knows that fieldToReturn is PageTypeLID, but something apparently goes wrong inside ORMSupportClasses, which I can cannot single-step into.

1) Exception Information


Exception Type: System.NullReferenceException Message: Object reference not set to an instance of an object. TargetSite: System.Object InternalGetValue() HelpLink: NULL Source: mscorlib

StackTrace Information


at System.Enum.InternalGetValue() at System.Enum.System.IConvertible.ToUInt16(IFormatProvider provider) at SD.LLBLGen.Pro.ORMSupportClasses.EntityPropertyDescriptor..ctor(IEntityField field, Type typeOfBindedObject) at BHCS.HTPN.Practices.BasePage.GetPageEntity(PageTypeEnum pt) in c:\htpn\practices\basepage.cs:line 221 at BHCS.HTPN.Practices.BasePage.GetPageEntity() in c:\htpn\practices\basepage.cs:line 234 at BHCS.HTPN.Practices.BasePage.GetContentEntity(ContentTypeEnum ct) in c:\htpn\practices\basepage.cs:line 144 at BHCS.HTPN.Practices.Home.GetIntroImage() in C:\HTPN\Practices\Home.aspx.cs:line 82 at BHCS.HTPN.Practices.Home.Page_Load(Object sender, EventArgs e) in C:\HTPN\Practices\Home.aspx.cs:line 97 at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain()

Fred avatar
Fred
User
Posts: 21
Joined: 04-Mar-2005
# Posted on: 25-Jan-2007 23:34:07   

Never mind. It's not a problem with ORMSupportClasses, it's this maddening habit either Visual Studio 2003 or Visual SourceSafe has, when you get latest on a project, of resetting the ORMSupportClasses reference from our buildoutput server back to my C: drive. I have version 2005 on my workstation, but some of our applications still use 2004.

VS sneakily resets that one reference frequently. and this time it resulted in crossed dll's because the GenPro classes were referencing the 2004 version and my app was looking at a 2005 version.