好像我在安装 Simple Injector MVC3 Integration 包的时候,SimpleInjectorInitializer 放在了 App_Start 文件夹中。但是,当在 Initialize() 中调用 Verify() 方法时,它会在尝试获取实体框架对象上下文时产生此错误(我还提供了内部异常):
The supplied connection string is not valid, because it contains insufficient mapping or metadata information.
InnerException: Unable to determine application context. The ASP.NET application path could not be resolved.
InnerException: Exception has been thrown by the target of an invocation.
InnerException: (Shown in browser) This method cannot be called during the application's pre-start initialization phase.
似乎我还必须将注册调用从 Global.asax.cs Application_Start() 移动到 SimpleInjectorInitializer 的 InitializeContainer() 方法。
我现在不完全确定该怎么做,但这个问题似乎与这个问题有点相关:升级到 Ninject 3.0.0-rc3 后的连接字符串异常
似乎应用程序正在尝试在实体框架甚至意识到它自己之前加载上下文并且无法正确解析连接字符串?