2015-02-06 100 views
0

我试图编写我自己的DNN 7模块,以了解。我是this tutorialDNN 7错误自定义模块

我创建了该模块,并显示此错误。

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 --- 

这里我的ascx代码

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

而且我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 
    { 

    } 
} 

搜索在谷歌链接我下面的代码,但我不知道这是解决方案(并且不知道如何正确使用它)

override protected void OnInit(EventArgs e) 
    { 
     InitializeComponent(); 
     base.OnInit(e); 
    } 
    private void InitializeComponent() 
    { 
     this.Load += new System.EventHandler(this.Page_Load); 
    } 
+0

看看这个链接。我现在使用这个模板多年来创建模块,它工作得很好。 http://dnntcmsbuild.codeplex.com/documentation – JK84 2015-02-06 10:09:33

+0

@ JK84:Thanx,但我不想使用模板。 – 2015-02-06 14:24:19

回答

2

您的ascx具有Inherits =“DesktopModules.HelloWorld”,但您的ascx.cs中的命名空间和类是“MyModules.HelloWorld”。另外,我会继承自DotNetNuke.Entities.Modules.PortalModuleBase而不是ModuleUserControlBase。

2

我强烈建议您重新考虑您的观点并开始使用Chris Hammond的模板或DotNetNuclear的模板。

如果没有其他原因,你可以盯着他们,向他们学习。 DotNetNuclear在dnnHero.com上的教程以及Chris在他的网站和dnnsoftware.com上的教程也是一个很好的开始。

而且,别让我在dnnsoftware.com上忘记克林特帕特森的一套教程。小学,但彻底,涵盖所有的基础,并回答许多初学者类型的问题。