1

初始化我的 ObjectFactory 时,我从 StructureMap 收到以下错误。

StructureMap.StructureMapException 发生 HResult=-2146232832
Message=StructureMap 异常代码:202 没有为 PluginFamily System.Collections.Generic.IDictionary 2[[System.Type, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Func2 [[System.Data.Entity.DbContext,EntityFramework,Version=5.0.0.0,Culture=neutral定义默认实例, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, 版本=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Source=StructureMap ErrorCode=202 StackTrace: at StructureMap.BuildSession.<.ctor>b__0(Type t) in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession。 cs:第 33 行内部异常:

从以前的答案来看,我似乎缺少对程序集的引用,但我现在包含了很多。这是我的完整初始化声明:

     ObjectFactory.Initialize(x =>
                                   {
                                       x.Scan(scan =>
                                                  {
                                                      scan.TheCallingAssembly();
                                                      scan.WithDefaultConventions();
                                                      scan.AssembliesFromApplicationBaseDirectory();
                                                  });
                                       x.For<IRepositoryProvider>().Use<RepositoryProvider>();
                                       x.For<IDataUow>().Use<DataInterface>();
                                       x.Forward<IDataUow, IDisposable>();
                                       x.For<RepositoryFactories>().Singleton();
                                   });
4

0 回答 0