OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.41k stars 2.39k forks source link

InvalidOperationException when using SeriLog #4560

Closed Allann closed 5 years ago

Allann commented 5 years ago

I created a copy of your Try Orchard repo and changed the logging to use Serilog using the unstructions here: https://orchardcore.readthedocs.io/en/dev/OrchardCore/OrchardCore.Logging.Serilog/readme/

but now I get the following InvalidOperationException.

2019-10-18 13:27:12.8500|||Microsoft.AspNetCore.Hosting.WebHost|FTL|Application startup exception
System.InvalidOperationException: No service for type 'OrchardCore.Modules.IApplicationContext' has been registered.
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseOrchardCore(IApplicationBuilder app, Action`1 configure) in C:\projects\orchardcore\src\OrchardCore\OrchardCore\Modules\Extensions\ApplicationBuilderExtensions.cs:line 18
   at FourMi.Web.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in E:\Repos\FourMi\Project\src\Clients\FourMi.Web\Startup.cs:line 41
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()

What am I missing? I included the package

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <TieredCompilation>true</TieredCompilation>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <PreserveCompilationReferences>true</PreserveCompilationReferences>

  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.0.0-rc1-10004" />
    <PackageReference Include="OrchardCore.Logging.Serilog" Version="1.0.0-rc1-10004" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
  </ItemGroup>

Have to supply a repo if needed.

Allann commented 5 years ago

My bad, I missed the AddOrchardCms in startup...