我得到一个异常调用解析:

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."}

有绝对是一个公共的无参数的构造函数那里(我已经验证了这一点,在运行时使用反射)...所以我推测问题可能与事实,这是通用的吗?我试着让组件模型对象,并设置RequiresGenericArguments为真,但是这并没有得到我的任何地方。

任何帮助,将不胜感激!感谢。

有帮助吗?

解决方案

温莎未使用默认的构造实例化活化剂。

新版本抛出一个更有用的异常消息:

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

所以你需要一个构造函数这样

public YourActivator(ComponentModel model, IKernel kernel,
                                    ComponentInstanceDelegate onCreation,
                                    ComponentInstanceDelegate onDestruction)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top