Object reference not set to an instance of an object.

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
2/8/2007 11:34:41 AM
Gravatar
Total Posts 6

Object reference not set to an instance of an object.

Hi,

I just compiled the source code of Mojo 2.2 and when I try to run it I get this error. I am using MySql and I did all settings in order to use it. I don;t know what to do...please help.


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:

Line 78: //currentPage = CacheHelper.GetCurrentPage();
Line 79:
Line 80: if (!CurrentPage.AllowBrowserCache)
Line 81: {
Line 82: SecurityHelper.DisableBrowserCache();


Source File: D:\@Work\Mojo 2.2\mojoportal\Web\Default.aspx.cs Line: 80

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
mojoPortal.Web.UI.Pages.SiteHome.Page_Load(Object sender, EventArgs e) in D:\@Work\Mojo 2.2\mojoportal\Web\Default.aspx.cs:80
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
2/8/2007 11:48:05 AM
Gravatar
Total Posts 18439

Re: Object reference not set to an instance of an object.

Are you getting that while running VS 2005 in debug mode?

That error is expected until the initial data is created. Just let it keep going when it hits that error, don't stop execution in the debugger, that error will hit the error handler and then you will be directed to the setup page.

Hope it helps,

Joe
2/8/2007 12:10:27 PM
Gravatar
Total Posts 6

Re: Object reference not set to an instance of an object.

you can check it on
http://86.124.125.50/mojoportal2/

I used it before and it worked, the MySql database remained the same(It has the update for 2.2 ver). I am a little bit confused...
2/8/2007 12:28:50 PM
Gravatar
Total Posts 18439

Re: Object reference not set to an instance of an object.

I think you still need to run the sql script upgradefrom2-2to2-2-1.sql

The error says its missing a column trying to get SiteSettings. The above script adds the column that is most likely missing.

Hope it helps,

Joe
2/8/2007 1:44:35 PM
Gravatar
Total Posts 6

Re: Object reference not set to an instance of an object.

Thanks Joe for all.

I have just deleted old database and recreated new one. It works now until
Welcome to mojoPortal Setup
No Sites have been created yet, click the button to create initial site data.

But when I click the button I get this:#42S22Unknown column 'LdapDomain' in 'field list' at MySql.Data.MySqlClient.PacketReader.CheckForError() in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\PacketReader.cs:line 149 at MySql.Data.MySqlClient.PacketReader.ReadHeader() in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\PacketReader.cs:line 117 at MySql.Data.MySqlClient.PacketReader.OpenPacket() in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\PacketReader.cs:line 131 at MySql.Data.MySqlClient.NativeDriver.ReadResult(Int64& affectedRows, Int64& lastInsertId) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\NativeDriver.cs:line 369 at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\CommandResult.cs:line 125 at MySql.Data.MySqlClient.CommandResult..ctor(Driver d, Boolean isBinary) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\CommandResult.cs:line 52 at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\NativeDriver.cs:line 330 at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\command.cs:line 295 at MySql.Data.MySqlClient.MySqlDataReader.NextResult() in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\datareader.cs:line 683 at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\command.cs:line 406 at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\command.cs:line 376 at MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar() in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\command.cs:line 419 at MySql.Data.MySqlClient.MySqlHelper.ExecuteScalar(MySqlConnection connection, String commandText, MySqlParameter[] commandParameters) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\MySqlHelper.cs:line 354 at MySql.Data.MySqlClient.MySqlHelper.ExecuteScalar(String connectionString, String commandText, MySqlParameter[] commandParameters) in D:\@Work\Mojo 2.2\mojoportal\MySQLConnector\MySqlClient\MySqlHelper.cs:line 318 at mojoPortal.Data.dbPortal.SiteSettings_Create(Guid siteGuid, String siteName, String skin, String logo, String icon, Boolean allowNewRegistration, Boolean allowUserSkins, Boolean allowPageSkins, Boolean allowHideMenuOnPages, Boolean useSecureRegistration, Boolean useSSLOnAllPages, String defaultPageKeywords, String defaultPageDescription, String defaultPageEncoding, String defaultAdditionalMetaTags, Boolean isServerAdminSite, Boolean useLdapAuth, Boolean autoCreateLDAPUserOnFirstLogin, String ldapServer, Int32 ldapPort, String ldapDomain, String ldapRootDN, String ldapUserDNKey, Boolean allowUserFullNameChange, Boolean useEmailForLogin, Boolean reallyDeleteUsers, String editorSkin, String defaultFriendlyUrlPattern, Boolean enableMyPageFeature) in D:\@Work\Mojo 2.2\mojoportal\MySQLData\dbPortal.cs:line 1405 at mojoPortal.Business.SiteSettings.Create() in D:\@Work\Mojo 2.2\mojoportal\Business\SiteSettings.cs:line 683 at mojoPortal.Business.SiteSettings.Save() in D:\@Work\Mojo 2.2\mojoportal\Business\SiteSettings.cs:line 807 at mojoPortal.Business.WebHelpers.mojoSetup.CreateInitialData() in D:\@Work\Mojo 2.2\mojoportal\mojoPortal.Business.WebHelpers\mojoSetup.cs:line 112 at mojoPortal.Web.UI.Pages.SetupHome.btnCreateInitialData_Click(Object sender, EventArgs e) in D:\@Work\Mojo 2.2\mojoportal\Web\Setup\Default.aspx.cs:line 139
Thank you again for all the help!

Cristian
2/8/2007 2:04:37 PM
Gravatar
Total Posts 18439

Re: Object reference not set to an instance of an object.

Hi,

I think you do not have the correct script for table creation. The 2.2.1.4 release files version of the script does include the LdapDomain column on mp_Sites, but the script you are using apparently does not.

You should download the 2.2.1.4 mysqldatalayer release files and use the script from there, I think maybe the source code zip did not have the up to date script, sorry about that.

Alternatively wait a few hours, I'm making a new set of release files today which will be version 2.2.1.5

Joe
2/8/2007 2:24:46 PM
Gravatar
Total Posts 6

Re: Object reference not set to an instance of an object.

ok Joe, thanks.

Cristian
2/8/2007 2:42:42 PM
Gravatar
Total Posts 6

Re: Object reference not set to an instance of an object.

I have just noticed this:
in mojoportal-2-2-1-4-mysqldatalayer
in file 2CreateTables.sql in
CREATE TABLE `mp_Pages` (
`PageID` int(11) NOT NULL auto_increment,
`ParentID` int(11) NOT NULL default '-1',
`PageOrder` int(11) NOT NULL default '0',
`SiteID` int(11) NOT NULL default '1',
`PageName` varchar(50) NOT NULL default '',
`PageTitle` varchar(255) NULL ,
`RequireSSL` tinyint(3) unsigned default '0',
`AllowBrowserCache` bit NOT NULL ,
`ShowBreadcrumbs` tinyint(3) unsigned default '0',
`PageKeyWords` varchar(255) default NULL,
`PageDescription` varchar(255) default NULL,
`PageEncoding` varchar(255) default NULL,
`AdditionalMetaTags` varchar(255) default NULL,
`MenuImage` varchar(50) default NULL,
`UseUrl` tinyint(3) unsigned NOT NULL default '0',
`Url` varchar(255) default NULL,
`OpenInNewWindow` tinyint(3) unsigned NOT NULL default '0',
`ShowChildPageMenu` tinyint(3) unsigned NOT NULL default '0',
`AuthorizedRoles` text,
`EditRoles` text,
`CreateChildPageRoles` text,
`ShowChildBreadcrumbs` tinyint(1) unsigned default '0',
`HideMainMenu` tinyint(1) unsigned default '0',
`Skin` varchar(100) default NULL,
`IncludeInMenu` tinyint(1) unsigned default '1',
PRIMARY KEY (`PageID`)
) ENGINE=InnoDB ;

`AllowBrowserCache` field does not have a default value. But in the script for upate upgradefrom2-1to2-2.sql  it's bit value is updated to 1.

 ALTER TABLE mp_Pages ADD COLUMN AllowBrowserCache bit;
UPDATE mp_Pages SET AllowBrowserCache = 1;

Has there to be a default value for 'AllowBrowserCache' in Create Table?

Cristian
2/8/2007 2:51:06 PM
Gravatar
Total Posts 18439

Re: Object reference not set to an instance of an object.

Its not required to have the default value because the code will send in a value when creating new rows so the default would not really be used.

However, null is not allowed so the upgrade script had to update that column to something for existing rows and 1 is what should be a default if there is a default.

Joe
2/8/2007 4:11:12 PM
Gravatar
Total Posts 18439

Re: Object reference not set to an instance of an object.

New 2.2.1.5 release files are out, let me know how it goes.

Thanks,

Joe
2/8/2007 4:41:51 PM
Gravatar
Total Posts 6

Re: Object reference not set to an instance of an object.

Something happens because I got an error similar to

#42S22Unknown column 'LdapDomain' in 'field list' at MySql.Data.MySqlClient.PacketReader.CheckForError()
....

but telling that `AllowBrowserCache`  does not have a default value. I added a default value for  `AllowBrowserCache` (`AllowBrowserCache` bit NOT NULL default 1) and now it works.
I didn't download 2.2.1.5 release files, but I will.

Thanks again for all the help!
I want to thank you also for the great job you do with Mojo.

Cristian

Iasi, Romania
You must sign in to post in the forums. This thread is closed to new posts.