You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a .Net Core 2.2 WebAPI project, An exception is thrown when registering a component with DependsOn after calling the AddWindsor method.
Used:
.Net Core 2.2.0
Castle.Windsor 5.0.0
Castle.Facilities.AspNetCore 5.0.0
Here you can find the code to reproduce the issue.
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Setup component model contributors for making windsor services available to IServiceProvider
Container.AddFacility<AspNetCoreFacility>(f => f.CrossWiresInto(services));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// Castle Windsor integration, controllers, tag helpers and view components, this should always come after RegisterApplicationComponents
var serviceProvider = services.AddWindsor(Container,
opts => opts.UseEntryAssembly(typeof(ValuesController).Assembly), // <- Recommended
() => services.BuildServiceProvider(validateScopes: false)); // <- Optional
// An exception is thrown when registering a component with DependsOn after calling the AddWindsor method.
Container.Register(
Component.For<IDemo>().ImplementedBy<Demo1>(),
Component.For<IDemo>().ImplementedBy<Demo2>(),
Component.For<IDemoService>().ImplementedBy<DemoService>().DependsOn(Dependency.OnComponent<IDemo, Demo2>()));
return serviceProvider;
}
Exception Message:
Object reference not set to an instance of an object.
StackTrace:
at Castle.Facilities.AspNetCore.Resolvers.GenericTypeExtensions.MatchesType(Type type, Type otherType)
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.<>c__DisplayClass15_0.b__0(ISubDependencyResolver s)
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.HasValidComponentFromResolver(DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.AddResolvableDependency(DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.AddDependency(DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.InitDependencies()
at Castle.MicroKernel.Handlers.AbstractHandler.Init(IKernelInternal kernel)
at Castle.MicroKernel.Handlers.DefaultHandlerFactory.Create(ComponentModel model)
at Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model)
at Castle.MicroKernel.Registration.ComponentRegistration`1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel)
at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations)
at Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations)
at CastleWindsorTest.Startup.ConfigureServices(IServiceCollection services) in Startup.cs:line 41
The text was updated successfully, but these errors were encountered:
fulinlin
changed the title
Castle.Facilities.AspNetCore Register issue
AspNetCoreFacility Component Register Issue
Mar 19, 2019
dariuslf
pushed a commit
to dariuslf/Windsor
that referenced
this issue
Jun 13, 2019
In a .Net Core 2.2 WebAPI project, An exception is thrown when registering a component with DependsOn after calling the AddWindsor method.
Used:
.Net Core 2.2.0
Castle.Windsor 5.0.0
Castle.Facilities.AspNetCore 5.0.0
Here you can find the code to reproduce the issue.
Exception Message:
Object reference not set to an instance of an object.
StackTrace:
at Castle.Facilities.AspNetCore.Resolvers.GenericTypeExtensions.MatchesType(Type type, Type otherType)
at System.Linq.Enumerable.Any[TSource](IEnumerable
1 source, Func
2 predicate)at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.<>c__DisplayClass15_0.b__0(ISubDependencyResolver s)
at System.Linq.Enumerable.Any[TSource](IEnumerable
1 source, Func
2 predicate)at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.HasValidComponentFromResolver(DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.AddResolvableDependency(DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.AddDependency(DependencyModel dependency)
at Castle.MicroKernel.Handlers.AbstractHandler.InitDependencies()
at Castle.MicroKernel.Handlers.AbstractHandler.Init(IKernelInternal kernel)
at Castle.MicroKernel.Handlers.DefaultHandlerFactory.Create(ComponentModel model)
at Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model)
at Castle.MicroKernel.Registration.ComponentRegistration`1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel)
at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations)
at Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations)
at CastleWindsorTest.Startup.ConfigureServices(IServiceCollection services) in Startup.cs:line 41
The text was updated successfully, but these errors were encountered: