-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
StructureMap and Orleans #4442
Comments
which structure map nugget are you using? I found this https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection on the internet show me install |
Hi, @xiazen! Thank you for your reply! Tried to use Autofac in a similar manner: var autofacSpFactory = new AutofacServiceProviderFactory();
var builder = new SiloHostBuilder()
.UseLocalhostClustering()
.UseServiceProviderFactory(autofacSpFactory); It throws the similar exception: "No accessible constructors were found for the type 'Orleans.Runtime.StatelessWorkerPlacement'." StackTrace: at Autofac.Core.Activators.Reflection.DefaultConstructorFinder.GetDefaultPublicConstructors(Type type)
at Autofac.Core.Activators.Reflection.ReflectionActivator..ctor(Type implementationType, IConstructorFinder constructorFinder, IConstructorSelector constructorSelector, IEnumerable`1 configuredParameters, IEnumerable`1 configuredProperties)
at Autofac.Builder.ConcreteReflectionActivatorData.get_Activator()
at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle](IRegistrationBuilder`3 builder)
at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle](IComponentRegistry cr, IRegistrationBuilder`3 builder)
at Autofac.ContainerBuilder.Build(IComponentRegistry componentRegistry, Boolean excludeDefaultModules)
at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
at Autofac.Extensions.DependencyInjection.AutofacServiceProviderFactory.CreateServiceProvider(ContainerBuilder containerBuilder)
at Orleans.Hosting.ServiceProviderFactoryAdapter`1.BuildServiceProvider(HostBuilderContext context, IServiceCollection services)
at Orleans.Hosting.ServiceProviderBuilder.BuildServiceProvider(HostBuilderContext context)
at Orleans.Hosting.SiloHostBuilder.Build()
at CoreLedger.Orleans.Host.CoreLedgerSilo.<StartSilo>d__8.MoveNext() in C:\Users\Mikhail PC\source\Workspaces\Coreledger Core\Dev\OrleansSilo\src\CoreLedger.Orleans.Host\CoreLedgerSilo.cs:line 183 |
Another option to inject a StructureMap is to provide a factory-lambda in var builder = new SiloHostBuilder()
.UseServiceProviderFactory(services =>
{
var ctr = new Container();
ctr.Populate(services);
return ctr.GetInstance<IServiceProvider>();
}) But it throws the same exception after calling to |
my wild guess is StructureMap requires everything injected into DI has a public constructor, which StatelessWorkerPlacement doesn't... it wasn't a problem with the native ASP.NET DI solution we uses, so we never run into this issue before. you are more familair with StructureMap than I'm, is this the case? if yes, Orleans may need to made code change for third party DI container like StructureMap to be integrated with Orleans. |
at the same time I will look into StructureMap. Just you are more familair with it supposeblely, so I figured I can just ask. |
yeah, you're right - StructureMap does require that all services it tries to instantiate need public constructors. when I have some spare time, I'll also try to investigate the way how Orleans could support this behaviour |
submitted pr #4453 which seems to fix the issue. |
Great, thank you! Hope this feel fix the issue. Waiting for a new release! |
Resolved via #4453. |
@sergeybykov was this released in |
@stephenlautier yes, this should be fixed in 2.0.3 - we made a change to fix it without having to revise the Abstractions package |
Hi! I try to integrate the StructureMap in Orleans (v 2.0.0).
I use the following code:
StructureMapServiceProviderFactory
implements a method:But call to
registry.Populate(services)
throws an exception:"Specified argument was out of the range of valid values.
Parameter name: Orleans.Runtime.StatelessWorkerPlacement must have at least one public constructor to be plugged in by StructureMap".
So, what is the correct way to inject StructureMap into Orleans DI framework?
The text was updated successfully, but these errors were encountered: