Search code examples
dotnetnuke2sxc

GetScopedService does not exist in the namespace ToSic.Sxc.Services, are you missing an assembly reference?


In 2sxc, trying to replace some old Factory/Render code in a clone of a site that is currently running DNN 9.10.02 and 2sxc is upgraded to v14.00.00.

I was doing the same thing as your recent blog article, Deep DNN Skin and Module Integration, the old way like this (from late 2019 or so)

<script runat="server">
// get 2sxc to Render() the output from the module on the SITE/Manage Flyout Links page
private string RenderFlyoutMenu()
  {
    // return ToSic.SexyContent.Environment.Dnn7.Factory.SxcInstanceForModule(419, 36).Render();
    return ToSic.Sxc.Dnn.Factory.CmsBlock(36, 419).Render();
  }
</script>
<%=RenderFlyoutMenu() %>

I am in Main.ascx theme file. To get started I figure I could just reuse the tab and module id from above in your example code from the blog and it would just work, so

<%@ Import Namespace="ToSic.Sxc.Dnn" %>
<%@ Import Namespace="ToSic.Sxc.Services" %>
<%= this.GetScopedService<IRenderService>().Module(36, 419) %>  

However, I get this error.

Could Not Load Theme: /Portals/_default/skins/accutheme/Main.ascx, 
Error: C:\...\www\Portals\_default\skins\accutheme\Main.ascx(14): 
error CS1061: 'portals__default_skins_accutheme_main_ascx' 
does not contain a definition for 'GetScopedService' and 
no accessible extension method 'GetScopedService' accepting 
a first argument of type 
'portals__default_skins_accutheme_main_ascx' 
could be found (are you missing a using directive 
or an assembly reference?)

Am I missing a reference to or import of something? If yes, its not obvious to me at the moment. What exactly hooks up the extension method to the UserControl (this)?


Solution

  • Thanks for the comment Daniel. For fun, before upgrading to v14.1, I tried it with the old name this.GetService and it worked. Upgraded to v14.1.0 (released 8 hours ago) and now the Blog's code samples work as expected.

    Thank you!!