私のソリューションでは、このような 3 つのプロジェクトがあります。
Common.dll と Service.dll を d:\libs のようなフォルダーにコピーし、タイプ scan で以下のコードを使用します。
ObjectFactory.Initialize(x =>
{
x.Scan(xx =>
{
xx.AssembliesFromPath(@"d:\libs");
xx.LookForRegistries();
});
});
//I have PersonService that implement IPersonService
namespace Common
{
public interface IPersonService
{
string SayHello(string name);
}
}
namespace Services
{
public class PersonService : IPersonService
{
public string SayHello(string name)
{
return string.Format("Hello {0}", name);
}
}
}
IPerson からインスタンスを取得するときに依存関係を初期化した後、このエラーが発生します
var personService = ObjectFactory.GetInstance<IPersonService>();
{"デフォルトのインスタンスが登録されておらず、タイプ 'Common.IPersonService' に対して自動的に決定できません\r\n\r\nCommon.IPersonService の構成が指定されていません\r\n\r\n1.) Container.GetInstance(Common .IPersonService)\r\n"}