Domanda

Mi sto un'eccezione Resolve chiamando:

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

C'è sicuramente un costruttore senza parametri pubblica lì (e ho verificato questo utilizzando la riflessione in fase di esecuzione) ... così ho dato il problema potrebbe avere a che fare con il fatto che è generica? Ho provato ricevendo il Component Object Model e l'impostazione RequiresGenericArguments al vero, ma questo non mi ha ottenuto da nessuna parte.

Qualsiasi aiuto sarebbe molto apprezzato! Grazie.

È stato utile?

Soluzione

Windsor non utilizza costruttore predefinito per attivatori istanziare.

La nuova versione lancia un messaggio di eccezione più utili:

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

Quindi è necessario un costruttore come questo

public YourActivator(ComponentModel model, IKernel kernel,
                                    ComponentInstanceDelegate onCreation,
                                    ComponentInstanceDelegate onDestruction)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top