ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Can´t locate IInjector .net 6 #293

Closed Pavesi99 closed 2 years ago

Pavesi99 commented 2 years ago

I have this function:

public static IServiceProvider BuildGraceServiceProvider(this IServiceCollection services) { services.NotifyOnBeforeCreateContainer(); var onBeforeCreateContainerHandlers = services.GetAllOnBeforeCreateContainerHandlers();

        var container = GraceFactory.ConfigureContainer();
        container.ConfigureService(services);

        var injector = container.Locate<IInjector>();

        onBeforeCreateContainerHandlers.Each(h => h.Invoke(injector));

        return injector;
    }

but when I call container.Locate() it throw this error: "Entry point was not found."

with this stack trace(): at Grace.DependencyInjection.Impl.BaseExportLocatorScope.GetOrCreateScopedService[T](Int32 id, ActivationStrategyDelegate createDelegate, IInjectionContext context) at Grace.DependencyInjection.Impl.InjectionScope.InternalLocate(IExportLocatorScope scope, IDisposalScope disposalScope, Type type, ActivationStrategyFilter consider, Object key, IInjectionContext injectionContext, Boolean allowNull, Boolean isDynamic) at Grace.DependencyInjection.Impl.InjectionScope.Grace.DependencyInjection.IInjectionScope.LocateFromChildScope(IExportLocatorScope childScope, IDisposalScope disposalScope, Type type, Object extraData, ActivationStrategyFilter consider, Object key, Boolean allowNull, Boolean isDynamic) at Grace.DependencyInjection.Impl.ActivationStrategyDelegateCache.FallbackExecution(ImmutableHashTree`2 currentNode, Type type, IExportLocatorScope scope, Boolean allowNull, IInjectionContext context) at Grace.DependencyInjection.Impl.ActivationStrategyDelegateCache.ExecuteActivationStrategyDelegate(Type type, IExportLocatorScope scope) at Grace.DependencyInjection.Impl.BaseExportLocatorScope.Locate(Type type) at Grace.DependencyInjection.Impl.BaseExportLocatorScope.Locate[T]() at Microsoft.Extensions.DependencyInjection.GraceServiceCollectionExtensions.BuildGraceServiceProvider(IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build()

It´s my first contact with Grace, I don´t know what is wrong..

eglauko commented 2 years ago

Some internal method has changed from version 7.0 to version 7.1, if you, @ipjohnson, remember and can guide us through what has changed, it will help us find the point more easily.

ipjohnson commented 2 years ago

Looking at the release notes I don't see any major changes between 7.0 -> 7.1.

What versions do you have of Grace and the hosting library?

Pavesi99 commented 2 years ago

I didn't look deep on my code to see what broke, I installed version 7.0 again and it´s work.

Thanks @eglauko and @ipjohnson