Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve service for type Orleans.Runtime.IPersistentState #40

Open
onurcanyilmaz opened this issue Oct 17, 2022 · 3 comments
Open

Comments

@onurcanyilmaz
Copy link

onurcanyilmaz commented Oct 17, 2022

I have aspnet core web api project, so I wanted to use Redis provider for clustering and storage.

Program.cs was like this

int db = 2;
string redisConnStr = "localhost:6379";

builder.Host.UseOrleans((host, builder) =>
{
    builder.AddRedisGrainStorage("RedisGrainStorage", optionsBuilder => optionsBuilder.Configure(options =>
    {
        options.ConnectionString = redisConnStr;
        options.UseJson = true;
        options.DatabaseNumber = db;
    }));

    builder.UseRedisClustering(options =>
    {
        options.ConnectionString = redisConnStr;
        options.Database = db;
    });

    builder.Configure<ClusterOptions>(options =>
    {
        options.ClusterId = "_basket_cluster";
        options.ServiceId = "_basket_service";
    });

    builder.Configure<EndpointOptions>(options =>
    {
        options.AdvertisedIPAddress = IPAddress.Loopback;
        options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, EndpointOptions.DEFAULT_GATEWAY_PORT);
        options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, EndpointOptions.DEFAULT_SILO_PORT);
    });

    builder.ConfigureLogging(logging => logging.AddConsole());
});

builder.Services.AddTransient<IBasketActor, BasketActor>();

And I have a grain with name is BasketActor
Then when I want to persistence my state with IPersistence

[StorageProvider(ProviderName = "RedisGrainStorage")]
    public class BasketActor : Grain, IBasketActor
    {
        public BasketActor(
            [PersistentState("basket", "RedisGrainStorage")] IPersistentState<BasketState> basket
            )
        {
        }
    }

And I have a grain with name is BasketActor
Then when I want to persistence my state with IPersistence
I am getting error this;

** Error while validating the service descriptor 'ServiceType:Basket.Actors.IBasketActor Lifetime: Transient ImplementationType: Basket.Actors.BasketActor': Unable to resolve service for type 'Orleans.Runtime.IPersistentState`1Basket.Actors.BasketState]' while attempting to activate 'Basket.Actors.BasketActor'.**

I've mentioned before in discord

Thanks.

@onurcanyilmaz onurcanyilmaz changed the title Unable to resolve service for type 'Orleans.Runtime.IPersistentState Unable to resolve service for type Orleans.Runtime.IPersistentState Oct 17, 2022
@wz172
Copy link

wz172 commented Nov 18, 2022

this builder.Services.AddTransient<IBasketActor, BasketActor>(); For what, Grain is not added that way.To use Part

@onurcanyilmaz
Copy link
Author

this builder.Services.AddTransient<IBasketActor, BasketActor>(); For what, Grain is not added that way.To use Part

builder.Services.AddTransient<IBasketActor, BasketActor>();

OK. I removed that line but nothing was happened. Same issue occured.
Have you ever else some solution?

By the way, Application parts has been removed for new version 7.0
source: https://learn.microsoft.com/en-us/dotnet/orleans/whats-new-in-orleans#packaging-changes

@onurcanyilmaz
Copy link
Author

onurcanyilmaz commented Jan 14, 2023

I think this provider is very important, so we have to use upon Redis properly by Orleans
Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants