Open OmerNassie opened 4 years ago
That's not the full stack trace. Lamar tries to give you the whole path of how you made the circle.
And I very strongly recommend against this usage here:
public override void ConfigureContainer(ServiceRegistry registry)
{
registry.For<IConfiguration>().Use(Configuration).Singleton();
registry.Scan(
c =>
{
c.WithDefaultConventions();
c.AssembliesFromApplicationBaseDirectory();
c.LookForRegistries();
});
}
That's going to give you oodles of registrations you don't need. Use some kind of allow list to limit the assemblies you're scanning, and that might very well make this problem go away
I managed to do a workaround for this because nothing I tried helped
registry.For(typeof(Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType)).Use(typeof(Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType));
registry.For<System.Security.Cryptography.X509Certificates.X509Certificate2>().Use<System.Security.Cryptography.X509Certificates.X509Certificate2>();
registry.For<System.Security.Cryptography.X509Certificates.X509Certificate>().Use<System.Security.Cryptography.X509Certificates.X509Certificate>();
While investigating the subject, I've already done a whitelist as for your recommendation. Thank you
I struggle understand the reason throwing this exception in my project. I searched all over the internet what can cause it while EntityFrameworkCore and AutoMapper are installed and using the
AssembliesFromApplicationBaseDirectory()
method when scanning for registries.The full exception message:
Detected some kind of bi-directional dependency while trying to discover and plan a missing service registration. Examining types: AutoMapper.TypePair, Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType
The project's dependencies:
my configure container method:
.Net Core 3.1