First noticed by @russblair mentioned on discord channel
Confirmed by @swegele
Repro:
Blazor Server-Interactive Only project (no wasm or any refs to new .NET 8 state management stuff)
Config in blazor server program.cs
builder.Services.AddCsla(o => o
.AddAspNetCore()
.AddServerSideBlazor(bsco => bsco
.UseInMemoryApplicationContextManager = true));
...
app.UseEndpoints(delegate (IEndpointRouteBuilder endpoint)
{
endpoint.MapControllers();
});
Csla config correctly skips making any reference or registration to any state management stuff. But none-the-less somehow .NET DI is looking for ISessionManager. We think that ASPNet is scanning the project (and it's dependencies) for controllers and it finds the [ApiController] attribute here:
Csla.AspNetCore.Blazor.State.StateController
[ApiController]
[Route("[controller]")]
public class StateController(ApplicationContext applicationContext, ISessionManager sessionManager) : ControllerBase
WORKAROUND
I did a test workaround suggested by @TheCakeMonster making a no-op implementation for the ISessionManager interface and registered it. With this the DI error goes away and project runs as expected.
using Csla.State;
public class NoOpSessionManager : ISessionManager
{
public Session GetCachedSession()
{ throw new NotImplementedException(); }
public Session GetSession()
{ throw new NotImplementedException(); }
public void PurgeSessions(TimeSpan expiration)
{ throw new NotImplementedException(); }
public Task<Session> RetrieveSession()
{ throw new NotImplementedException(); }
public Task SendSession()
{ throw new NotImplementedException(); }
public void UpdateSession(Session newSession)
{ throw new NotImplementedException(); }
}
...
builder.Services.AddSingleton<Csla.State.ISessionManager, NoOpSessionManager>();
First noticed by @russblair mentioned on discord channel
Confirmed by @swegele
Repro:
Blazor Server-Interactive Only project (no wasm or any refs to new .NET 8 state management stuff)
Config in blazor server program.cs
Csla config correctly skips making any reference or registration to any state management stuff. But none-the-less somehow .NET DI is looking for
ISessionManager. We think that ASPNet is scanning the project (and it's dependencies) for controllers and it finds the[ApiController]attribute here:Csla.AspNetCore.Blazor.State.StateController
WORKAROUND
I did a test workaround suggested by @TheCakeMonster making a no-op implementation for the
ISessionManagerinterface and registered it. With this the DI error goes away and project runs as expected.