A critical error has occurred. Object reference not set to an instance of an object.
Last Post 08/25/2011 7:39 PM by Joseph Craig. 18 Replies.
Author Messages Not Resolved
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 10:33 AM  
I have written a simple module to search for members and display them with picture as a gallery with a link to their user profile. The module was registered well and I can add them to the page (included in menu) in portal...when the page is clicked on menu, I debugged that it calls my code properly and executes the code in page_load well till the end - but somewhere after that it fails with an error "A critical error has occurred. Object reference not set to an instance of an object". FYI, the same page_load code called from an individual aspx file shall show the results fine and no crash at all. This means the code is OK but somehow it doesn't show the module results viewing. I read all the forums about this problem, updated the RadEditorProvider and also the DDR menu to be compatible with dot net 6. NO use AT ALL. Does anyone have a solution for this? I am on a deadline to decide on dotnetnuke or build my own...

The event viewer shows the following traces...

AssemblyVersion: 6.0.0

PortalID: 0

PortalName: Awesome Friends

UserID: 1

UserName: aditya

ActiveTabID: 83

ActiveTabName: My Search

RawURL: /MySearch.aspx

AbsoluteURL: /Default.aspx

AbsoluteURLReferrer: http://localhost:3408/Admin.aspx

UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.20) Gecko/20110803 Firefox/3.6.20 (.NET CLR 3.5.30729)

DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider

ExceptionGUID: 0e33f084-7e26-4fcc-a924-ea6635946406

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

FileName:

FileLineNumber: 0

FileColumnNumber: 0

Method: DotNetNuke.Web.DDRMenu.DDRMenuControl.OnPreRender

StackTrace:

Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Web.DDRMenu.DDRMenuControl.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---

Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 11:00 AM  
Most likely, you aren't initializing something in your code. Without seeing it, it's hard to figure out.

Have you tried debugging this with your code integrated with DotNetNuke? Are you able to step through the code to see exactly where things are falling apart?

Joe Craig, Patapsco Research Group
Complete DNN Support
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 11:01 AM  
If you remove your module from the MySearch page, does the page load correctly? Then, does adding it back generate the error again?

Look for things like PortalId or ModuleId not being set correctly.

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 12:08 PM  
Hi Joseph, thank you so much for replying - how do i know what to initialize, in the page_load code...i pasted the code that was working in a standalone aspx page. I saw that that the code in my debugger has passed well out of page_load but I don't know where it is failing down the road. I can give the code but where do i look for the portalid or moduleid not being set correctly or not.
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 12:20 PM  
I think that I'd probably need to look at your code.

You said that you created a module by copying code from an aspx page that otherwise works just fine. How did you insure that the DotNetNuke module you created inherits from the appropriate DotNetNuke classes? In other words, how did you build the module?

Do you have an installable zip file for the module?

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 12:30 PM  
Hi Joseph, I used the dynamic module from VS studio starter kit to create the module and then renamed the folders as well as running the sql script as per the module creation instructions...and then in the page_load, i replaced the code that runs in my aspx page - compiled the site and registered the module - i don't know if i have messed up anything but everything seemed proper step. I don't have a installable zip file for the module...but i have the folder with dnn manifest file - let me know. Thanks again for helping me out...let me know how i can provide you with the information.
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 12:48 PM  
If you have all of this installed on a local system, you should be able to open and run DotNetNuke in Visual Studio. If so, you can debug the module using all of the tools available in VS.

There are some nice video tutorials by Chris Hammond on the DotNetNuke website that describe installation and debugging.

------
You never answered the question about what happens if you remove your module from the page. Does the site then run properly. If that is true, that's a pretty solid indication that the issue is in your module and not elsewhere. But, I think that the error you posted verifies that, too.

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 12:54 PM  
Hi Joseph, when i removed the module from the page, no issue on that page and anyway i have just that page not working with this module and rest of the site works well with no issues. Do i need to have the dotnetnuke source to debug further? my page_load code in the module was just fine but it is crashing later on...
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 1:05 PM  
No, you don't need to have the source for DotNetNuke to debug your module.

If you have the site running locally, just open DotNetNuke in VS. You should then be able to set breakpoints in your module's code and trace execution of your module to see where it is breaking.

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 2:08 PM  
Hi Joseph, i am seeing the following traces in my log.resources - do you think there is any issue with the module naming or the acsx file where runat server was used many times?

2011-08-24 15:13:04,975 [RGWS-1150][Thread:11][ERROR] DotNetNuke.UI.Skins.Pane - You can only have one <head runat="server"> control on a page.
System.Web.HttpException: You can only have one <head runat="server"> control on a page.
at System.Web.UI.HtmlControls.HtmlHead.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content)
at DotNetNuke.UI.Modules.ModuleHost.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at DotNetNuke.UI.Modules.ModuleHost.get_ModuleControl()
at DotNetNuke.UI.Containers.Container.get_ModuleControl()
at DotNetNuke.UI.Containers.Container.ProcessModule()
at DotNetNuke.UI.Containers.Container.SetModuleConfiguration(ModuleInfo configuration)
at DotNetNuke.UI.Skins.Pane.InjectModule(ModuleInfo module)
2011-08-24 15:13:05,084 [RGWS-1150][Thread:11][ERROR] DotNetNuke.UI.Skins.Skin - Unhandled Error Adding Module to ContentPane
DotNetNuke.Services.Exceptions.ModuleLoadException: Unhandled Error Adding Module to ContentPane ---> System.Web.HttpException: You can only have one <head runat="server"> control on a page.
at System.Web.UI.HtmlControls.HtmlHead.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content)
at DotNetNuke.UI.Modules.ModuleHost.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at DotNetNuke.UI.Modules.ModuleHost.get_ModuleControl()
at DotNetNuke.UI.Containers.Container.get_ModuleControl()
at DotNetNuke.UI.Containers.Container.ProcessModule()
at DotNetNuke.UI.Containers.Container.SetModuleConfiguration(ModuleInfo configuration)
at DotNetNuke.UI.Skins.Pane.InjectModule(ModuleInfo module)
--- End of inner exception stack trace ---
at DotNetNuke.UI.Skins.Pane.InjectModule(ModuleInfo module)
at DotNetNuke.UI.Skins.Skin.InjectModule(Pane pane, ModuleInfo module)
2011-08-24 15:13:05,209 [RGWS-1150][Thread:11][ERROR] DotNetNuke.UI.Containers.ActionBase - FriendlyMessage="An error has occurred." ctrl="ASP.desktopmodules_ddrmenu_actions_ascx" exc="System.NullReferenceException: Object reference not set to an instance of an object.
at DotNetNuke.UI.Containers.ActionBase.get_ModuleContext()
at DotNetNuke.UI.Containers.ActionBase.get_ActionRoot()
at DotNetNuke.UI.Containers.ActionBase.OnLoad(EventArgs e)"
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 2:15 PM  
You've probably done one of the things mentioned in the last couple of messages in this thread:

http://www.dotnetnuke.com/Resources...posts.aspx

Joe Craig, Patapsco Research Group
Complete DNN Support
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 2:15 PM  
Simply, a module is an ascx control, not an aspx page.

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 2:23 PM  
Joseph, thank you so much for your support on this issue - you are really the master and expert who responded by my sheer luck. It worked and I am very glad about this...I would like to document this process of writing a module and contribute such that no one has to face the same issue.

Thank you so much Joseph.
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 2:31 PM  
There are some really good resources for creating modules.

1. Mitchel Sellers' book Professional DotNetNuke Module Programming
2. Chris Hammonds series of video tutorials at DotNetNuke.com
3. Michael Washington and Ian Lackey's book
4. Michael Washington's adefwebserver.com website

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/24/2011 3:27 PM  
Hi Joseph, one more question on module installation - i chose to create a new module as manifest and selected dnn file in a folder. I had this folder "SomeModuleName" under DesktopModules Directory. I don't remember creating this kind of folder under Admin directory. But after installation i am seeing this new folder. Is this normal? when i debug it stops only in the code under DesktopModules/SomeModuleName - what is the directory structure for the module and i mean where all it gets created into
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 3:34 PM  
Your module should be installed in a subdirectory of DesktopModules. Since I'm not quite sure what you did, I'm not sure which directory is correct. Do you have more than one directory in DesktopModules?

Joe Craig, Patapsco Research Group
Complete DNN Support
Joseph Craig
DNN MVP
Posts:11667


--
08/24/2011 4:06 PM  
That's one of the reasons that upgrades should first be done on a copy of live sites.

That said, do you know which menu is being used? That the page appears in your menu may be a good sign.

I'd probably have to look into your site to figure this one out.

Joe Craig, Patapsco Research Group
Complete DNN Support
Aditya Ayyagari
Nuke Newbie
Nuke Newbie
Posts:8


--
08/25/2011 3:05 PM  
Thanks joseph for your reply. I actually used host->extension -> Manage -> Create new Module action to create a new module. In the page, I selected manifest installation and selected the dnn file from the folder SomeModuleName under the DesktopModules and that is the folder for the module i guess and the debugger stops in that code. But my question is there is one more folder of the same name SomeModuleName created under the DesktopModules/Admin folder - this is not created by me but i guess something else caused to created this directory. The code inside is just identical to the good one but debugger never stopped in that code - so i believe it is a useless code under the DesktopModule/Admin directory - question was to see if i can delete that folder? I can leave it as is too (no issue at the moment) - but want to understand a bit more.
Joseph Craig
DNN MVP
Posts:11667


--
08/25/2011 7:39 PM  
If you are going to be developing modules for DotNetNuke, you owe it to yourself to get a copy of Mitchel Sellers' book and that you view Chris Hammond's video tutorials (and some blog entries) that are available at DotNetNuke.com. You might also want to get a copy of the book by Michael Washington and Ian Lackey.

Joe Craig, Patapsco Research Group
Complete DNN Support


---