Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesSystem.NullReferenceException: Object reference not set to an instance of an objectSystem.NullReferenceException: Object reference not set to an instance of an object
Previous
 
Next
New Post
8/23/2012 11:52 AM
 

Hello 

I'm creating a custom module and I'm getting the following error below. I'm using Steve Fabian's Gooddog template (which works fine) but I'm trying to apply a multi-view using code from Managing Views In Your DotNetNuke Module by Rafe Kemmis.

If I comment out the following code in BOLD I don't get any error:

protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

System.Web.UI.Control parent = Parent as System.Web.UI.Control;

                while (!(parent is PortalModuleBase))
                {
                    parent = parent.Parent;
                }
                ModuleConfiguration = ((PortalModuleBase)parent).ModuleConfiguration;


}

AssemblyVersion: 6.2.2

PortalID: 0

PortalName: CSCDNN

UserID: 1

UserName: host

ActiveTabID: 82

ActiveTabName: DirectoryIII

RawURL: /DirectoryIII.aspx

AbsoluteURL: /Default.aspx

AbsoluteURLReferrer: http://localhost/DirectoryIII.aspx

UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1

DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider

ExceptionGUID: e578bfb6-7f64-41d2-ba50-50b1d4dc0305

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

FileName: C:\DNN\DesktopModules\DirectoryIII\Common\DirectoryIIIModuleBase.cs

FileLineNumber: 17

FileColumnNumber: 17

Method: CSC.DNN.DirectoryIIIModuleBase.OnInit

StackTrace:

Message: System.NullReferenceException: Object reference not set to an instance of an object. at CSC.DNN.DirectoryIIIModuleBase.OnInit(EventArgs e) in C:\DNN\DesktopModules\DirectoryIII\Common\DirectoryIIIModuleBase.cs:line 17 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content) at System.Web.UI.Control.EnsureChildControls() at DotNetNuke.UI.Containers.Container.get_ModuleControl() at DotNetNuke.UI.Containers.Container.ProcessModule() at DotNetNuke.UI.Skins.Pane.InjectModule(ModuleInfo module)

Source:

Server Name: jfrick


 
New Post
8/27/2012 3:23 PM
 

Hi, Jeff

Well it seems that the bold line syntax is not c# as the rest of your code, if you are trying to do a cast it must be:

System.Web.UI.Control parent = (System.Web.Ui.Control)Parent;

that "as" is from Visual Basic (as far as i know). Then parent never gets a value and in the next query for parent value will throw a null reference exception, well thats what it seems to me.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesSystem.NullReferenceException: Object reference not set to an instance of an objectSystem.NullReferenceException: Object reference not set to an instance of an object


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out