简体   繁体   English

DNN 7错误自定义模块

[英]DNN 7 Error custom Module

I'm trying to code my own DNN 7 module, to learn. 我正在尝试编写自己的DNN 7模块,以进行学习。

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 这是我的ascx代码

<%@ 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 还有我的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) 在google上搜索将我链接到以下代码,但是我不确定这是否是解决方案(并且不知道如何正确使用它)

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". 您的ascx具有Inherits =“ DesktopModules.HelloWorld”,但您的ascx.cs中的名称空间和类是“ MyModules.HelloWorld”。 Also, I would inherit from DotNetNuke.Entities.Modules.PortalModuleBase instead of ModuleUserControlBase. 另外,我将从DotNetNuke.Entities.Modules.PortalModuleBase继承,而不是从ModuleUserControlBase继承。

I would strongly recommend that you reconsider your point of view and start using either Chris Hammond's template or DotNetNuclear's template. 我强烈建议您重新考虑您的观点,并开始使用Chris Hammond的模板或DotNetNuclear的模板。

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. dnnHero.com上的DotNetNuclear教程以及其站点和dnnsoftware.com上的Chris教程也是一个不错的起点。

And, don't let me forget Clint Patterson's set of tutorials at dnnsoftware.com. 而且,不要让我忘记dnnsoftware.com上Clint Patterson的教程集。 Elementary, but thorough and cover all the bases and answer many beginner type questions. 基本但全面,涵盖所有基础并回答许多初学者类型的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM