DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

NavigationManager

Sort:
You are not authorized to post a reply.
Page 2 of 3 << < 123 > >>





Advanced Member





    So you're still getting this error message?

    'IServiceProvider' does not contain a definition for 'GetRequiredService' and no accessible extension method 'GetRequiredService' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

    Here's a patch of what changed to add INavigationProvider to a control inside DNN:

    From 9a37ad164f11e8a258f16aa055659cbe2c703b78 Mon Sep 17 00:00:00 2001
    From: Brian Dukes 
    Date: Mon, 27 Jan 2020 09:28:25 -0600
    Subject: [PATCH] Add NavigationManager to WebForms control
    
    ---
     .../Admin/Authentication/Authentication.ascx.cs        | 10 ++++++++++
     1 file changed, 10 insertions(+)
    
    diff --git a/DNN Platform/Website/DesktopModules/Admin/Authentication/Authentication.ascx.cs b/DNN Platform/Website/DesktopModules/Admin/Authentication/Authentication.ascx.cs
    index 5f0153433a..483646c003 100644
    --- a/DNN Platform/Website/DesktopModules/Admin/Authentication/Authentication.ascx.cs	
    +++ b/DNN Platform/Website/DesktopModules/Admin/Authentication/Authentication.ascx.cs	
    @@ -9,12 +9,16 @@
     using System.IO;
     using System.Web.UI;
     using System.Web.UI.HtmlControls;
    +
    +using DotNetNuke.Abstractions;
     using DotNetNuke.Entities.Modules;
     using DotNetNuke.Services.Authentication;
     using DotNetNuke.Services.Localization;
     using DotNetNuke.UI.Skins.Controls;
     using DotNetNuke.UI.UserControls;
     
    +using Microsoft.Extensions.DependencyInjection;
    +
     #endregion
     
     namespace DotNetNuke.Modules.Admin.Authentication
    @@ -27,8 +31,14 @@ namespace DotNetNuke.Modules.Admin.Authentication
     	/// 
     	public partial class Authentication : PortalModuleBase
     	{
    +        private readonly INavigationManager _navigationManager;
     
     		private readonly List _settingControls = new List();
    +        /// 
    +        public Authentication()
    +        {
    +            this._navigationManager = this.DependencyProvider.GetRequiredService();
    +        }
     
     		protected override void OnLoad(EventArgs e)
     		{
    -- 
    2.25.0.windows.1
    
    
    DNN partner specializing in custom, enterprise DNN development https://engagesoftware.com/showcase





    Veteran Member





      Hi Brian,

      yes, I am still on this error. The only difference I see is here:

         this._navigationManager = this.DependencyProvider.GetRequiredService();
      
      

      In my code it reads as

         _navigationManager = DependencyProvider.GetRequiredService();
      
      

      Thanks for your patience.

      Happy DNNing!
      Michael

      Michael Tobisch
      DNN★MVP

      dnnWerk Austria
      DNN Connect





      Advanced Member





        Can you show me your project file (or just the references from that file)?
        DNN partner specializing in custom, enterprise DNN development https://engagesoftware.com/showcase





        Veteran Member





          Hi Brian,

          two are custom stuff, but here are the other references ({ = <, } = >):

              {Reference Include="DotNetNuke, Version=6.1.1.12, Culture=neutral, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\DotNetNuke.dll{/HintPath}
              {/Reference}
              {Reference Include="DotNetNuke.Abstractions, Version=9.4.4.0, Culture=neutral, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\DotNetNuke.Abstractions.dll{/HintPath}
              {/Reference}
              {Reference Include="DotNetNuke.DependencyInjection, Version=9.4.4.0, Culture=neutral, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\DotNetNuke.DependencyInjection.dll{/HintPath}
              {/Reference}
              {Reference Include="DotNetNuke.Web"}
                {HintPath}..\..\bin\DotNetNuke.Web.dll{/HintPath}
              {/Reference}
              {Reference Include="Custom1, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\Custom1.dll{/HintPath}
              {/Reference}
              {Reference Include="Custom2, Version=6.0.0.0, Culture=neutral, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\Custom2.dll{/HintPath}
              {/Reference}
              {Reference Include="Microsoft.ApplicationBlocks.Data, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\Microsoft.ApplicationBlocks.Data.dll{/HintPath}
              {/Reference}
              {Reference Include="Microsoft.Extensions.DependencyInjection, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"}
                {SpecificVersion}False{/SpecificVersion}
                {HintPath}..\..\bin\Microsoft.Extensions.DependencyInjection.dll{/HintPath}
              {/Reference}
              {Reference Include="System" /}
              {Reference Include="System.Data" /}
              {Reference Include="System.Data.DataSetExtensions" /}
              {Reference Include="System.Drawing" /}
              {Reference Include="System.Web" /}
              {Reference Include="System.Web.ApplicationServices" /}
              {Reference Include="System.Web.DynamicData" /}
              {Reference Include="System.Web.Entity" /}
              {Reference Include="System.Web.Extensions" /}
              {Reference Include="System.Xml" /}
              {Reference Include="System.Xml.Linq" /}
              {Reference Include="WindowsBase" /}
          
          

          Happy DNNing!
          Michael

          Michael Tobisch
          DNN★MVP

          dnnWerk Austria
          DNN Connect





          Veteran Member





            Solved...

            A reference to Microsoft.Extensions.DependencyInjection.Abstractions was required...

            Thanks, Brian, for your help!

            Happy DNNing!
            Michael

            Michael Tobisch
            DNN★MVP

            dnnWerk Austria
            DNN Connect





            New Around Here





              Hi Michael/Brian
              Sadly [for me] I'm an occasional Basic Code producer of DNN Modules.
              I have a a couple of modules that have worked fine for four years... until I 'upgraded' to DNN 9.5.0 which appears [I think] to be broken in that calls to NavigateURL is generating very odd behavior.

              I have a Development machine that, after compilation, works fine.

              On the Operational machine, It seems that the Request.Params being passed to an editing sub-form have 'moved up one' in that Params((3) is now Params(4). As a result, I get errors across the piece.

              I've read the dialog between Brian and Michael... didn't really understand much of that  but if you could point me at a basic code example of how the new NavigateURL mechanism is implemented, that would be great.

              ... Still not at all sure why it works in one machine and not the other... the /bin DlLLs are all precisely the same, so I suspect some Microsoft based software is at fault. Any ideas?

              Regards and in some desparation,
              Duncan






              Advanced Member





                In Visual Basic.NET, the base of indexers can be set to 0 (the default) or 1 (see Option Base statement docs). So it's possible that something in your toolchain is changing the base, which would result in this kind of error. I don't think it would have anything to do with the new INavigationManager.

                DNN partner specializing in custom, enterprise DNN development https://engagesoftware.com/showcase





                New Around Here





                  update:
                  I've been chasing a ghost.

                  Because I use Request.Params to pass a number of parameters to sub-dialogs, [which has always worked...].
                  And when I updated to 9.5.0 I casually added a local language [English:UK] to the site... DotNetNuke added that to each parameter set ! :)

                  ... A lesson learned.

                  However, I'd still like to see a Basic Code example of the update to NavigateUrl() function as that will be removed in version 11.0

                  regards,
                  Duncan






                  New Around Here





                    Here is a full synopsis of how to move from the old NavigateURL to the new method

                    References for your project must be made to:

                    • DotNetNuke.Abstractions
                    • Microsoft.Extensions.DependencyInjection
                    • Microsoft.Extensions.DependencyInjection.Abstractions
                    • * the dlls can be found in the bin directory
                       
                    • DotNetNuke.Abstractions is required for INavigationManager and must be declared above as an imports or using (depending on language) before your class definition
                    • Microsoft.Extensions.DependencyInjection is required as an imports/using so that you can call on the PortalModuleBase.DependencyProvider


                    Each of these returns a string which you can then do redirects with or whatever.

                    • The old way - Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "YourControlKey", "mid=" & CStr(ModuleId))
                    • The new way - DependencyProvider.GetRequiredService(Of INavigationManager).NavigateURL(PortalSettings.ActiveTab.TabID, "YourControlKey", "mid=" & CStr(ModuleId))


                    If you want to circumvent the call to DotNetNuke.Abstractions you can call it like this:
                    DependencyProvider.GetRequiredService(Of Abstractions.INavigationManager).NavigateURL(PortalSettings.ActiveTab.TabID, "YourControlKey", "mid=" & CStr(ModuleId))






                    New Around Here





                      Now if someone could please explain why the dev team decided to add all the extra layers to obtain the same functionality??

                      Three more dlls, two more using/import statements and a longer, more complex line that no longer works on the front page of a module control.
                      You are not authorized to post a reply.
                      Page 2 of 3 << < 123 > >>

                      These Forums are dedicated to the discussion of DNN Platform.

                      For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

                      1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
                      2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
                      3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
                      4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
                      5. No Flaming or Trolling.
                      6. No Profanity, Racism, or Prejudice.
                      7. Site Moderators have the final word on approving / removing a thread or post or comment.
                      8. English language posting only, please.

                      Would you like to help us?

                      Awesome! Simply post in the forums using the link below and we'll get you started.

                      Get Involved