Skip to content

Circular reference in IServiceProvider when using Autofac DI #2747

Closed
@Maarten88

Description

I upgraded to Orleans 1.4.0, and got an error from Autofac, which I use as my DI framework with Orleans instead of the default Microsoft DI. When starting the Silo host, Autofac complains:

Circular component dependency detected: Orleans.GrainFactory -> System.IServiceProvider -> System.IServiceProvider.

And then the silo refuses to start. It seems Microsoft DI is more forgiving, returning services.BuildServiceProvider() instead of AutofacServiceProvider(builder.Build()) with the exact same registrations results in a succesful start of the silo.

Runtime/OutsideRuntimeClient.cs line 110 reads:

services.AddSingleton(sp => sp);

My guess is that Autofac does not like that, it seems circular indeed so I guess this causes the bug. I'm not sure why that line is there; it seems it can be safely deleted?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions