0
votes

I'm trying to code my own DNN 7 module, to learn.

I'm actually following this tutorial.

I've created the module, and it show this error.

Error: HelloWorld is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. --->
System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl()
--- End of inner exception stack trace ---

Here my ascx code

<%@ Control Language="C#"
    AutoEventWireup="true"
    CodeFile="HelloWorld.ascx.cs"
    Inherits="DesktopModules.HelloWorld"
%>
<h1>Hello Dude</h1>
<p>Some text here</p>

And my ascx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.UI.Modules;

namespace MyModules
{
    public partial class HelloWorld : ModuleUserControlBase
    {

    }
}

Searching on google link me to the following code, but I'm not sure this is the solution (and don't know how to use it properly)

override protected void OnInit(EventArgs e)
    {
        InitializeComponent();
        base.OnInit(e);
    }
    private void InitializeComponent()
    {
        this.Load += new System.EventHandler(this.Page_Load);
    }
2
Take a look at this link. I,m using this template now for years to create modules and it works great. dnntcmsbuild.codeplex.com/documentationJK84
@JK84 : Thanx, but I do not want to use template.Bart Bartoman

2 Answers

2
votes

Your ascx has Inherits="DesktopModules.HelloWorld", but your namespace and class in your ascx.cs is "MyModules.HelloWorld". Also, I would inherit from DotNetNuke.Entities.Modules.PortalModuleBase instead of ModuleUserControlBase.

2
votes

I would strongly recommend that you reconsider your point of view and start using either Chris Hammond's template or DotNetNuclear's template.

If for no other reason, you can stare at them and learn from them. DotNetNuclear's tutorials at dnnHero.com and Chris' tutorial on his site and at dnnsoftware.com are also a great place to start.

And, don't let me forget Clint Patterson's set of tutorials at dnnsoftware.com. Elementary, but thorough and cover all the bases and answer many beginner type questions.