2015-02-06 90 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上忘記克林特帕特森的一套教程。小學,但徹底,涵蓋所有的基礎,並回答許多初學者類型的問題。