.NET 6 new (minimal) hosting model with CMS 12 giving exception at startup

Vote:
 

Hello!

I'm trying to use the new minimal hosting model that was introduced in .NET 6 but I'm stumbling against an error that I'm unsure of how to resolve. the app runs fine on the old hosting model with .NET 6, so this isn't a blocker, but it would be nice though.

The exeption I'm getting at startup is:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at EPiServer.Shell.Modules.ModuleInitializer.RegisterNlsRoute(String name, String path, ShellModule shellModuleNamedShell, ShellModule module, String clientResourcePath, IEndpointRouteBuilder routeBuilder)
at EPiServer.Shell.Modules.ModuleInitializer.RegisterClientResourceRoutes(IEnumerable`1 modules, IEndpointRouteBuilder routeBuilder)
at EPiServer.Shell.Routing.ShellEndpointRoutingExtension.InitializeModules(IEndpointRouteBuilder routeBuilder, IEnumerable`1 modules)
at EPiServer.Shell.Routing.ShellEndpointRoutingExtension.MapEndpoints(IEndpointRouteBuilder endpointRouteBuilder)
at EPiServer.Web.Routing.EndpointRouteBuilderExtensions.MapEPiServerExtensionEndpoints(IEndpointRouteBuilder defaultEndpointRouteBuilder)
at EPiServer.Web.Routing.ContentEndpointRouteBuilderExtensions.MapContent(IEndpointRouteBuilder defaultEndpointRouteBuilder)
at Web.Startup.<>c__DisplayClass3_0.<Configure>b__0(IEndpointRouteBuilder endpoints) in C:\Dev\Experiments\Web\Startup.cs:line 311
at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
at Web.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Dev\Experiments\Web\Startup.cs:line 309
at Program.<Main>$(String[] args) in C:\Dev\Experiments\Web\Program.cs:line 19

The Program.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Web;

// New hosting model (not starting)

var builder = WebApplication.CreateBuilder(args);

builder.Host.ConfigureCmsDefaults();

var configuration = builder.Configuration;
var environment = builder.Environment;

var startup = new Startup(configuration);

startup.ConfigureServices(builder.Services);

var app = builder.Build();

startup.Configure(app, environment);

app.Run();

// Old hosting model (starting)

var builder = Host.CreateDefaultBuilder(args);

builder.ConfigureCmsDefaults();

builder.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());

var app = builder.Build();

app.Run();

Is the new hosting model supported by CMS 12 yet or am I missing something?

#280398
May 16, 2022 15:28
Vote:
 

If I remember rightly it's not supported yet due to some internal complexities of Optimizely on the ordering of how things run. Same goes for minimal APIs, I beleve they are working on an update.

#280445
May 17, 2022 9:15
Vote:
 

Unfortunately we do not support the new hosting model yet. We have to introduce breaking changes to our initialization to make it work, that's why we decided to wait.

#280467
May 17, 2022 15:49
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.