Question

Je reçois une exception appelant 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."}

Il y a certainement un constructeur de parameterless publique là-bas (et je l'ai vérifié cette réflexion à l'aide à l'exécution) ... alors je me dis que le problème pourrait avoir à voir avec le fait qu'il est générique? J'ai essayé d'obtenir l'objet modèle de composants et la mise à RequiresGenericArguments vrai, mais qui ne m'a pas eu nulle part.

Toute aide serait grandement appréciée! Merci.

Était-ce utile?

La solution

Windsor n'utilise pas constructeur par défaut pour activateurs instancier.

La nouvelle version lance un message d'exception plus utile:

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

Vous avez donc besoin d'un constructeur comme ceci

public YourActivator(ComponentModel model, IKernel kernel,
                                    ComponentInstanceDelegate onCreation,
                                    ComponentInstanceDelegate onDestruction)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top