z4kn4fein / stashbox

A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
https://z4kn4fein.github.io/stashbox
MIT License
141 stars 10 forks source link

Unable to resolve Orleans.Runtime.IKeyedServiceCollection`2[System.Type,Orleans.Runtime.Placement.IPlacementDirector] #132

Closed dmitrig89 closed 1 year ago

dmitrig89 commented 1 year ago

When adding StashBox to a project using Microsoft Orleans, the host is unable to resolve the following type:

Orleans.Runtime.IKeyedServiceCollection`2[System.Type,Orleans.Runtime.Placement.IPlacementDirector]

The following versions were used to when encountering this issue:

Microsoft.Extensions.Hosting Version=7.0.1
Microsoft.Orleans.Server Version=7.1.1
Stashbox.Extensions.Hosting Version=4.6.0

The simplest reproduction of this issue can be seen in the following example:

using Microsoft.Extensions.Hosting;

await Host.CreateDefaultBuilder(args)
    .UseOrleans(siloBuilder =>
    {
        siloBuilder.UseLocalhostClustering();
    })
    .RunConsoleAsync();

This code runs fine and starts up an instance of an Orleans Silo on a localhost.

When adding stashbox, the as seen below, the following error is produced:

using Microsoft.Extensions.Hosting;

await Host.CreateDefaultBuilder(args)
    .UseStashbox()
    .UseOrleans(siloBuilder =>
    {
        siloBuilder.UseLocalhostClustering(); ;
    })
    .RunConsoleAsync();
 System.InvalidOperationException: No service for type 'Orleans.Runtime.IKeyedServiceCollection`2[System.Type,Orleans.Runtime.Placement.IPlacementDirector]' has been registered.
z4kn4fein commented 1 year ago

Hi @dmitrig89, thank you for reporting this! I've found the root cause and fixed it in Stashbox v5.8.1. I've also published a new Stashbox.Extensions.Hosting package with the version v4.6.1. Let me know if you have further issues!

dmitrig89 commented 1 year ago

Amazing!!!

Thanks @z4kn4fein.

I can confirm this no longer happens on v5.8.1

Very quick work, much appreciated.