几年前我已经放弃了StructureMap或者更多 - 使用过Ninject,很多时候要么项目要么没有IOC容器,要么“有些”其他容器。
我打算从项目中的这个2.6.x版本升级到4.x(我认为现在可能是5.x了)
好像我的新服务不喜欢
public static IContainer Initialize()
{
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
x.For<INotificationService>().Use<NotificationService>();
x.For<IMailClient>().Use<MailClient>();
x.For<INotifierFactory>().Use<NotifierFactory>();
x.For<ILogService>().Use<LogService>();
x.For<IInternService>().Use<InternService>();
});
return ObjectFactory.Container;
}
{"StructureMap Exception Code: 202\nNo Default Instance defined for PluginFamily PublicHealth.Intern.DataAccess.Data.UnitOfWork.IInternUnitWork, PublicHealth.Intern.DataAccess.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}
我确实看到了这些SO引用
StructureMap Exception Code: 202 No Default Instance defined for PluginFamily
StructureMap Exception Code: 202 No Default Instance defined for PluginFamily
StructureMap Exception Code: 202 No Default Instance defined for PluginFamily
我不确定某些解决方案/建议是否对我有用。
例如
This problem was fixed by replacing ObjectFactory.Initialize with ObjectFactory.Configure and adding the assemblies in my project:
:/
如果有帮助,我可以提供更多代码。