orleans icon indicating copy to clipboard operation
orleans copied to clipboard

DependencyResolutionException while using Autofac & SMS

Open srinathgnath opened this issue 8 years ago • 6 comments

Hello,

After start using SMS in Host configuration, I have been having below exceptions.

Exception 1: DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = IGrainStorage (DelegateActivator), Services = [Orleans.Storage.IGrainStorage], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope Exception 2: DependencyResolutionException: A delegate registered to create instances of 'Orleans.Storage.IGrainStorage' returned null.

Code Snippet: var builder = new SiloHostBuilder() .Configure(options => options.ClusterId = "TestCluster") .UseDevelopmentClustering( options => options.PrimarySiloEndpoint = new IPEndPoint(siloAddress, siloPort)) .ConfigureEndpoints(siloAddress, siloPort, gatewayPort) .AddMemoryGrainStorage("PubSubStore") .AddSimpleMessageStreamProvider("Teststream") .UseServiceProviderFactory(Startup.ConfigureServices) .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IEventAggregator).Assembly).WithReferences());

Startup: public static IServiceProvider ConfigureServices(IServiceCollection services) { var builder = new ContainerBuilder(); builder.Populate(services); builder.RegisterModule(); var container = builder.Build(); //Create the IServiceProvider based on the container. return new AutofacServiceProvider(container); }

srinathgnath avatar Apr 05 '18 19:04 srinathgnath

Thanks Team. Closing this issue as it worked fine after correcting memorygrainstorage configuration.

srinathgnath avatar Apr 06 '18 14:04 srinathgnath

I have similar issue with ado storage. Can you please explain what is were wrong in your configuration? Thanks

ifle avatar Apr 16 '18 16:04 ifle

After adding memorygrainstorageasdefault configuration, it worked. .AddMemoryGrainStorageAsDefault()

srinathgnath avatar Apr 16 '18 22:04 srinathgnath

I think the failure is due to missing config on Default grain storage. @srinathgnath is trying to configure memory grain storage, so they should call AddMemoryGrainStorageAsDefault. @ifle if you want to use Ado Storage, then you should call AddAdoGrainStorageAsDefault

xiazen avatar Apr 16 '18 23:04 xiazen

@srinathgnath @xiazen Thanks a lot. Adding AddMemoryGrainStorageAsDefault is fixed this error. Please add the configuration validation, that will very helpful.

ifle avatar Apr 17 '18 06:04 ifle

As @xiazen said, may be you should call AddAdoGrainStorageAsDefault as you are implementing adonet storage. COuld you please post your silohost adonet configuration. Now when I tried ado.net, getting below exceptions:

  1. OrleansLifecycleCanceledException: Lifecycle start canceled due to errors at stage 10000
  2. InvalidOperationException: Sequence contains no matching element

srinathgnath avatar Apr 17 '18 14:04 srinathgnath