简体   繁体   中英

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

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. 在此处输入图像描述

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?

I'm a bit confused about you mentioning the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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