StructureMap异常:没有为PluginFamily System.Collections.Generic.IDictionary2定义默认实例

时间:2012-09-12 01:56:14

标签: asp.net-mvc structuremap

我在初始化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.Func -2 - [[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,版本= 4.0.0.0,文化=中性,   PublicKeyToken = b77a5c561934e089]],mscorlib,Version = 4.0.0.0,   Culture = neutral,PublicKeyToken = b77a5c561934e089 Source = StructureMap   ErrorCode = 202 StackTrace:          在StructureMap.BuildSession。< .ctor> b__0(类型t)c:\ BuildAgent \ work \ 767273992e840853 \ src \ StructureMap \ BuildSession.cs:line   33 InnerException:

从以前的答案来看,我似乎错过了对集会的引用,但我现在包括了很多。这是我的完整初始化声明:

     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();
                                   });

0 个答案:

没有答案