0
IListにコンストラクタの依存関係がありますが、解決できません(以下の例外を参照してください)というオブジェクト(Contextクラス)を解決しようとしています。誰もがなぜこれが説明できますか? castleと.netの一般的な例外に問題はありますか?回答IListに依存するcastleの型を解決する際の問題
をありがとうpublic class Context : IContext
{
public Context(
IApplicationSite applicationSite,
IList<Currency> currencies)
{
}
}
そして、これは私のIOC登録です:
var _container = new WindsorContainer();
_container.Kernel.AddFacility<FactorySupportFacility>();
_container.Register(
Component.For<IRepository>()
.ImplementedBy<Repository>()
.Named("repository"));
_container.Register(
Component
.For<IList<Currency>>()
.UsingFactoryMethod(kernel => kernel.Resolve<IRepository>().GetCurrencies())
.Named("currencies"));
_container.Register(
Component
.For<IApplicationSite>()
.UsingFactoryMethod(kernel => kernel.Resolve<IRepository>().GetApplicationSite())
.Named("applicationSite"));
_container.Register(
Component.For<IContext>()
.ImplementedBy<Context>()
.Named("Context"));
var _context = _container.Resolve<IContext>();
私は、次の例外を取得状況を解決しよう:
Castle.MicroKernel.Resolvers.DependencyResolverException : Could not resolve non-optional dependency for 'Context' (ClassLibraryCastle.Context).
Parameter 'currencies' type 'System.Collections.Generic.IList`1[[ClassLibraryCastle.Currency, ClassLibraryCastle, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'
[よくある質問](http://stw.castleproject.org/Windsor.FAQ.ashx#Why_is_Windsor_not_able_to_inject_array_or_list_of_components_8)で説明されています。 –