Je ne comprends pas l'erreur que je reçois comme indiqué au bas de cette question. Pourquoi le conteneur tente-t-il de lancer l'objet, en particulier si le compilateur le fait sans erreur? J'utilise v2.0.0.5642.Erreur d'instanciation d'objet dans Castle Windsor
Je suis sûr que c'est dans la configuration, mais je suis perdu. J'apprécierais vraiment toute aide.
<component id="cipherMaster" type="Demo.View.UserControls.CipherMaster, Demo.View" />
<component id="cipherVariation" service="Demo.View.UserControls.CipherMaster, Demo.View"
type="Demo.View.UserControls.CipherVariation, Demo.View" />
<component id="presenterVariation" service="Demo.Model.Interfaces.IDemoTypePresenter, Demo.Model"
type="Demo.Presenter.PresenterVariation, Demo.Presenter" >
<cipherPanel>${cipherVariation}</cipherPanel>
</component>
namespace Demo.Presenter
{
public class PresenterCipherMaster : IDemoTypePresenter
{
...
}
}
namespace Demo.Presenter
{
public class PresenterVariation : PresenterCipherMaster
{
private readonly CipherVariation _variation;
public PresenterVariation(IMasterDemo view, CipherMaster cipherPanel, FeaturesVariation features,
IEncryptionEngine engine):base(view, cipherPanel, features, engine)
{
_variationLog = new List<CipherVariationLog>();
_variation = (CipherVariation) cipherPanel; //<<< Cast error points here line 18
...
}
}
}
public static class IocContainer
{
public static T Resolve<T>(string key)
{
T presenter = Container.Resolve<T>(key); //<<< Error occurs here
return presenter;
}
}
namespace Demo.View.UserControls
{
public partial class CipherMaster : UserControl
{
...
}
}
namespace Demo.View.UserControls
{
public partial class CipherVariation : CipherMaster
{
...
}
}
=====================
Castle.MicroKernel.ComponentActivator.ComponentActivatorException was unhandled
Message="ComponentActivator: could not instantiate Demo.Presenter.PresenterVariation"
Source="Castle.MicroKernel"
StackTrace:
...
InnerException: System.Reflection.TargetInvocationException
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
...
InnerException: System.InvalidCastException
Message="Unable to cast object of type 'Demo.View.UserControls.CipherMaster' to type 'Demo.View.UserControls.CipherVariation'."
Source="Demo.Presenter"
StackTrace:
at Demo.Presenter.PresenterVariation..ctor(IMasterDemo view, CipherMaster cipherPanel, FeaturesVariation features, IEncryptionEngine engine) in E:\Development\MainStreamDemo\Demo.Presenter\PresenterVariation.cs:line 18
InnerException: