I have never used Windsor before, but used a different DI framework, and for now I have a rather strange problem.
I have a factory class that takes a string in its constructor, however whenever I try to resolve this object, I get an exception:
Handler for System.String was not found. <Message>Handler for System.String was not found.</Message> <StackTrace>at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.TryGetHandlerFromKernel(DependencyModel dependency, CreationContext context) in d:\60b7fa65294e7792\src\Castle.Windsor\MicroKernel\Resolvers\DefaultDependencyResolver.cs:line 403 at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ComponentModel model, DependencyModel dependency) in d:\60b7fa65294e7792\src\Castle.Windsor\MicroKernel\Resolvers\DefaultDependencyResolver.cs:line 270</StackTrace> <Type>Castle.MicroKernel.Handlers.HandlerException</Type> </InnerException> <Message>Missing dependency. Component SomeExampleFactory has a dependency on System.String, which could not be resolved. Make sure the dependency is correctly registered in the container as a service, or provided as inline argument.</Message>
The class looks something like this:
public interface IDummyFactory { void DoSomething(); } public class DummyFactory : IDummyFactory { private string someString; public DummyFactory(string someConstructorArg) { someString = someConstructorArg; } }
With the DI setting below:
var someString = "some constructor arg"; _container.Register(Component.For<IDummyFactory>().ImplementedBy<DummyFactory>().DependsOn(someString));
I assume that he is trying to do some kind of discarding or formatting, which will cause it to start, but since the type itself is a string and the variable is passed in the string ... it could even be that it tries to match the type of this variable, not the contents of the variable, but I donβt know enough about the DI structure and documentation for this area.
source share