Type Initialization Exception

Posts   
 
    
glynnd
User
Posts: 3
Joined: 04-Mar-2008
# Posted on: 04-Mar-2008 18:09:50   

Hi,

We've been working fine with LLBL for about a year now. We use version 2.0.0.0 Final.

We build our ASP.Net application on our test servers before uploading to our live server.

We use LLBL to build our Data layer completley and the data layer project (DAL) it creates is a project within our solution.

We have an issue where everything works fine on our testing server but not on the live server.

The DAL compiles OK and has been deployed to live server but when we try to access a specific collection using the GetMulti method it generates an exception in your code.

All other collection seem to be OK.

The stack trace is show below:

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.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] Intersalon.DAL.EntityClasses.SalonSmsSettingsEntity..cctor() +42

[TypeInitializationException: The type initializer for 'Intersalon.DAL.EntityClasses.SalonSmsSettingsEntity' threw an exception.] Intersalon.DAL.EntityClasses.SalonSmsSettingsEntity..ctor() +0 Intersalon.DAL.FactoryClasses.SalonSmsSettingsEntityFactory.Create() +45 Intersalon.DAL.FactoryClasses.SalonSmsSettingsEntityFactory.Create(IEntityFields fields) +37 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery) +1357 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize) +270 SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, Int32 pageNumber, Int32 pageSize) +119 SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter) +29 CMSDesk_Tools_Salon_Appointment_SMS.LoadData() +155 CMSDesk_Tools_Salon_Appointment_SMS.Page_Load(Object sender, EventArgs e) +124 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Control.OnLoad(EventArgs e) +99 CMSPage.OnLoad(EventArgs e) +9 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 04-Mar-2008 18:24:20   

hmm, you say this happen only in the production server? could you please post the code which originates this exception?

glynnd
User
Posts: 3
Joined: 04-Mar-2008
# Posted on: 04-Mar-2008 18:48:54   

Thanks for the response.

I can repro the exception on the production server by simply doing the following:

SalonSmsSettingsCollection sc = new SalonSmsSettingsCollection(); IPredicateExpression filter = new PredicateExpression(); filter.Add(new FieldCompareValuePredicate(SalonSmsSettingsFields.SiteId, ComparisonOperator.Equal, CMS.CMSHelper.CMSContext.CurrentSite.SiteID)); sc.GetMulti(filter);

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Mar-2008 11:15:38   

Would you please post the LLBLGen pro runtime library version used?check the following thread for guidelines on how to find the RTL version number: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725

The only thing that's called inside the static/shared CTor is the SetupCustomPropertyHashtables method, would you please post that routine here (from the entity class).

Are you sure this is not re-produce on the testing server? If so would you please check any version mismatch between both servers, and also any configuration option mismatch.

glynnd
User
Posts: 3
Joined: 04-Mar-2008
# Posted on: 06-Mar-2008 20:04:46   

I was about to reply with all the information you requested but it seems gathering it all I've stumbled upon the problem.

We extended the entity class with some of our own custom properties, merging together a few fields etc. Some of these additional properties pulled some data from elements in web.config.

We upgraded our application and it seems that the web.config on the server does not now contain the required fields.

It seems one of our engineers had problems with the upgrade on the live server database and during his debugging he rolled back to an old version of web.config and once the database was fixed forgot to reinstate web.config.

Sorry for wasting your time rage but thanks for the prompt responses, its certainly been refreshing.