DNN 7 Error custom Module

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);
    }

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.


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.

链接地址: http://www.djcxy.com/p/43828.html

上一篇: 将文件夹添加到自定义DNN扩展

下一篇: DNN 7错误自定义模块