简体   繁体   English

尝试将 2sxc 应用程序注入 DNN 模板时出错

[英]Error when trying to inject 2sxc app into DNN template

I'm trying to inject a 2sxc app into a DNN template file - as per this great tutorial from WolfXMachina我正在尝试将 2sxc 应用程序注入 DNN 模板文件 - 根据WolfXMachina的这篇精彩教程

Tutorial code:教程代码:

<%@ Import Namespace="DotNetNuke.Entities.Modules" %>
<%@ Import Namespace="ToSic.Sxc.Dnn" %>
<%@ Import Namespace="ToSic.Sxc.Services" %>
 <%
    var moduleController = new ModuleController();
    ModuleInfo footerModule = moduleController.GetModule(39, 394);
    if (footerModule != null) {
  %>
    <%= this.GetScopedService<IRenderService>().Module(39, 394) %>
  <%
    }
  %>

I checked for the page id and grabbed the ID for the app from the 2sxc app list.我检查了页面 ID,并从 2sxc 应用程序列表中获取了该应用程序的 ID。 在此处输入图像描述

But I'm getting the following error (Object reference not set to an instance of an object):但是我收到以下错误(对象引用未设置为对象的实例):

    DotNetNuke.Services.Exceptions.Exceptions - DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at ToSic.Sxc.Dnn.DnnModuleAndBlockBuilder.GetModuleImplementation(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Core\Dnn\DnnModuleAndBlockBuilder.cs:line 30
   at ToSic.Sxc.Blocks.ModuleAndBlockBuilder.GetBlock(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\ModuleAndBlockBuilder.cs:line 25
   at ToSic.Sxc.Blocks.RenderService.Module(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\Renderers\RenderService.cs:line 124
   at ToSic.Sxc.Dnn.Services.DnnRenderService.Module(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Core\Dnn\Services\DnnRenderService.cs:line 37

What I'm I doing wrong or is there another location where I can get the app ID?我做错了什么,或者是否有其他位置可以获取应用程序 ID?

I'm a bit confused about you mentioning the AppId.我对你提到 AppId 有点困惑。 It also doesn't appear in your code above, and you don't need it.它也没有出现在您上面的代码中,您也不需要它。

Basically you would add a module to any page - usually hidden.基本上你会添加一个模块到任何页面——通常是隐藏的。

Then you would use the ID of that page and module for this.然后您将为此使用该页面和模块的 ID。

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

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