Search code examples
xamarin.formsprism

Logger service not found in prism


My setup is :

<PackageReference Include="Prism.DryIoc.Extensions" Version="7.2.0.1054" />
<PackageReference Include="Prism.Forms.Extended" Version="7.2.0.1054" />
<PackageReference Include="Shiny.Prism" Version="7.2.0.1054" />

 protected override void RegisterTypes(IContainerRegistry containerRegistry)
     {
         containerRegistry.RegisterServices(services => 
            {
                services.AddLogging();
             }
      }

and when i try to get service to assign to property as below :

` Logger = provider.GetRequiredService<ILogger<AgentBase>>(); `

This error happens :

`No service for type 'Microsoft.Extensions.Logging.ILogger`1[Hyperledger.Aries.Agents.AgentBase]' has been registered.`

is there any missing config ?


Solution

  • In my project Dryioc is the main container that prism use for Di but my objects are completely depend on Microsoft DI, also some of class must registered from internal access modifier.

    Replacing DryIOC with Microsoft Di not recommended by prism team, but there is an extension for combining .

    finally after combining them and some change in dryioc setting for internal class registration, it worked .

    Also error was solved after Host Builder correct initialization.

    Thankyou