Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas 35 posts 115 karma points
    Jul 21, 2023 @ 14:36
    Thomas
    0

    Umbraco composer in razor class library

    Hi, I have razor class library and inside this I have DI registered in Umbraco builder. This razor class library is dynamically refer in main web application. When I run web application the razor class library DI is not resolved

    Anyone have idea to handle this?

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 21, 2023 @ 16:56
    Huw Reddick
    1

    how exactly are registering it?

  • Thomas 35 posts 115 karma points
    Jul 21, 2023 @ 17:35
    Thomas
    0

    Hi Reddick,

    The dependencies are registered in razor class library

      public class FileWatcherComposer : IComposer
      {
        public void Compose(IUmbracoBuilder builder)
        {
            builder.Services.AddScoped<IFileWatcherService, FileWatcherService>();
        }
      }
    
  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 21, 2023 @ 18:06
    Huw Reddick
    0

    That should be fine, what is the error you are getting, if any?

  • Thomas 35 posts 115 karma points
    Jul 21, 2023 @ 18:10
    Thomas
    0

    Its showing Unable to resolve the dependency IFileWatcherService when its invoked But its working when the razor class library is refer in main web app directly (add project reference). But its not working when its loaded at runtime (dynamically loaded assembly - ApplicationPartManager)

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 22, 2023 @ 07:20
    Huw Reddick
    0

    If you are loading at runtime then the composer will not run. Are you loading at run time for a specific reason? If so you will need to register the service differently

  • Thomas 35 posts 115 karma points
    Jul 22, 2023 @ 10:18
    Thomas
    0

    Yes, When I run my web application it should read (dynamically loaded) the razor class library dll and update the Umbraco web app to use external app.

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 22, 2023 @ 15:33
  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Jul 24, 2023 @ 12:23
Please Sign in or register to post replies

Write your reply to:

Draft