【发布时间】:2012-07-10 12:44:48
【问题描述】:
好像我在安装Simple Injector MVC3 Integration 包的时候,SimpleInjectorInitializer 放在了App_Start 文件夹下。但是,当在 Initialize() 中调用 Verify() 方法时,在尝试获取 Entity Framework Object Context 时会产生此错误(我也提供了内部异常):
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() 方法。
我现在不完全确定该怎么做,但这个问题似乎与这个问题有些相关:Connection string exception after upgrading to Ninject 3.0.0-rc3
似乎应用程序在 Entity Framework 意识到它自己之前尝试加载上下文并且无法正确解析连接字符串?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 dependency-injection ioc-container simple-injector