Spring.Net抛出异常:请求在此上下文中不可用

时间:2014-08-07 19:03:26

标签: asp.net-mvc-4 spring.net

我对Spring很新,所以有些决定对我来说并不清楚 这是ASP.NET MVC4 / .NET 4.5应用程序

这是一个例外文本:

An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in Spring.Core.dll but was not handled in user code
Additional information: Error creating context 'spring.root': Request is not available in this context

自定义上下文管理器类中出现错误:

    public static IApplicationContext GetApplicationContext()
    {
        if (null == appContext)
        {
            lock (typeof(ContextManager))
            {
                if (null == appContext)
                {
                    appContext = ContextRegistry.GetContext(); <-- throws there
                }
            }
        }
        return appContext;
    }

我用谷歌搜索了许多解决方案,告诉我将 IIS模式切换到集成模式。在该模式下,应用程序运行正常,但我需要使用 IISExpress 调试应用程序。而且没有任何想法

这个例外有我的堆栈跟踪:

at System.Configuration.BaseConfigurationRecord.EvaluateOne(String [] keys,SectionInput input,Boolean isTrusted,FactoryRecord factoryRecord,SectionRecord sectionRecord,Object parentResult)
   在System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord,SectionRecord sectionRecord,Object parentResult,Boolean getLkg,Boolean getRuntimeObject,Object&amp; result,Object&amp; resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey,Boolean getLkg,Boolean checkPermission,Boolean getRuntimeObject,Boolean requestIsHere,Object&amp; result,Object&amp; resultRuntimeObject)
   在System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   在System.Web.HttpContext.GetSection(String sectionName)
   在System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)
   在System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
   在System.Configuration.ConfigurationManager.GetSection(String sectionName)
   在Spring.Util.ConfigurationUtils.GetSection(String sectionName)
   在Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded()
   在Spring.Context.Support.ContextRegistry.GetContext()
   在~~ \ Model \ ContextManager.cs中的HealthDec.Cms.Model.ContextManager.GetApplicationContext()中:第46行    在~~ \ Model \ ContextManager.cs中的HealthDec.Cms.Model.ContextManager.GetObject(String name):第64行    在~~ \ Applications \ WebApp \ Global.asax.cs中的HealthDec.Cms.WebApp.MvcApplication.Init()中:第156行    在System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo []处理程序)

1 个答案:

答案 0 :(得分:2)

解决方案资源管理器 - &gt;选择MVC项目 - &gt; “属性”标签 - &gt;管理管道模式 - &gt;集成的&lt; - &gt;经典