문제

I'm getting an exception calling Resolve:

KernelException: Could not instantiate custom activator
Inner Exception:
{"Constructor on type 'MyProj.MyAdapter`1[[MyProj.MyBusinessObject, MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' not found."}

There's definitely a public parameterless constructor there (and I've verified this using reflection at runtime)...so I figure the problem might have to do with the fact that it's generic? I've tried getting the component model object and setting RequiresGenericArguments to true, but that hasn't gotten me anywhere.

Any help would be much appreciated! Thanks.

도움이 되었습니까?

해결책

Windsor is not using default constructor to instantiate activators.

The new version throws a more helpful exception message:

Castle.MicroKernel.KernelException : Could not instantiate custom activator
  ----> System.ArgumentException : Type Castle.Windsor.Tests.ActivatorWithoutCorrectConstructor does not have a public constructor matching arguments of the following types:
Castle.Core.ComponentModel
Castle.MicroKernel.DefaultKernel
Castle.MicroKernel.ComponentInstanceDelegate
Castle.MicroKernel.ComponentInstanceDelegate

So you need a constructor like this

public YourActivator(ComponentModel model, IKernel kernel,
                                    ComponentInstanceDelegate onCreation,
                                    ComponentInstanceDelegate onDestruction)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top