Application does not run

Topics: Developer Forum, Project Management Forum
Mar 3, 2008 at 9:24 AM

I tried running the sample application using the source as available on the N2 site, but it gives

“Object reference not set to an instance of an object”

please HELP

Mar 3, 2008 at 4:26 PM
Which sample application did you download?
Did you try any of the examples on the releases tab?
Do you have a stack trace that might give a clue about the problem?

Mar 30, 2008 at 3:14 PM
Donno if scusers solved the problem, but I've run into the same one! I was trying to run the N2 1.3.2 Templates and got the following error msg and stack trace:
Object with id: 38 was not of the specified sublcass: N2.ContentItem (Discriminator was: 'TrashContainerItem')

Stack trace:
WrongClassException: Object with id: 38 was not of the specified sublcass: N2.ContentItem (Discriminator was: 'TrashContainerItem')
NHibernate.Loader.Loader.GetInstanceClass(IDataReader rs, Int32 i, ILoadable persister, Object id, ISessionImplementor session) +205
NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session) +42
NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session) +271
NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) +176
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +494
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +56
NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object id, IType type) +231
NHibernate.Loader.Collection.CollectionLoader.Initialize(Object id, ISessionImplementor session) +28
NHibernate.Persister.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session) +59
NHibernate.Impl.SessionImpl.InitializeCollection(IPersistentCollection collection, Boolean writing) +375
NHibernate.Collection.AbstractPersistentCollection.Initialize(Boolean writing) +111

LazyInitializationException: Failed to lazily initialize a collection
NHibernate.Collection.AbstractPersistentCollection.Initialize(Boolean writing) +195
NHibernate.Collection.Generic.PersistentGenericBag`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +13
N2.Collections.ItemList`1.AddRange(IEnumerable`1 items, ItemFilter[] filters) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Collections\ItemList.generic.cs:72
N2.Collections.ItemList`1..ctor(IEnumerable`1 items, ItemFilter[] filters) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Collections\ItemList.generic.cs:47
N2.Collections.ItemList..ctor(IEnumerable`1 items, ItemFilter[] filters) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Collections\ItemList.cs:32
N2.ContentItem.GetChildren(ItemFilter[] filters) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\ContentItem.cs:500
N2.ContentItem.GetChildren(String childZoneName) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\ContentItem.cs:491
N2.Templates.Items.AbstractPage.GetChildren(String childZoneName) in C:\Anokha\N2CMS\1.3.2\src\Templates\N2.Templates\Items\AbstractPage.cs:32
N2.Templates.Items.AbstractPage.GetChildren(String childZoneName) in C:\Anokha\N2CMS\1.3.2\src\Templates\N2.Templates\Items\AbstractPage.cs:35
N2.Web.UI.WebControls.Zone.GetItems() in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Web\UI\WebControls\Zone.cs:88
N2.Web.UI.WebControls.Zone.get_DataSource() in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Web\UI\WebControls\Zone.cs:52
N2.Web.UI.WebControls.Zone.CreateItems(Control container) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Web\UI\WebControls\Zone.cs:125
N2.Web.UI.WebControls.Zone.CreateChildControls() in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Web\UI\WebControls\Zone.cs:119
System.Web.UI.Control.EnsureChildControls() +87
N2.Web.UI.WebControls.Zone.OnInit(EventArgs e) in C:\Anokha\N2CMS\1.3.2\src\Core\N2\Web\UI\WebControls\Zone.cs:69
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +834

wud be very grateful for any help
Mar 30, 2008 at 7:09 PM
Hi there,

A curiosity, what package did you download?

The error is due to a type of item stored in the database not beeing registered in the application.

One way this could happen would throwing something (deleting stuff cause a trash container to be created) and then deleting n2.edit.trash.dll. Now sure how it happened for you though. Maybe you could fill in the details?

Grabbing the latest release (upgrade) would help since the trash container is included in n2.edit.dll

Apr 1, 2008 at 7:00 PM
Gosh....I'm impressed by the speed of your reply!

I downloaded the 'N2 Sources 1.3.2' package even though it's not the latest one since it seemed to be more complete and 1.3.3 version don't have an assabeled package of all the code yet.

I then just open the N2.Templates-vs2008.sln file, compile (works fine) and run the application and end up with the error above :-(

Maybe I'm doing somethin altogether wrong, but am quite new to the system.

Apr 1, 2008 at 8:16 PM
Aha. The templates needs some dependencies that needs to be built first. In the later versions there's a msbuild script that can do this for you (src/Prepare_Dependencies-vs2008.bat should do it). You can download the sources from here. By the way I'll probably upload a new version in a few.
Apr 2, 2008 at 5:50 PM
Thanks alot Cristian!
Now I got it! For future reference I think it could be a good thing to include a short description of all the batch jobs.