IIS服务器和Spring.NET对象实例化失败 [英] IIS Server and Spring.NET object instantiation failed

查看:312
本文介绍了IIS服务器和Spring.NET对象实例化失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的web应用程序中使用Spring.NET。在开始申请被设置为使用Visual Studio开发服务器。一切都工作正常。但是,当我改变了它使用本地IIS Web服务器并创建了一个虚拟目录,然后运行我得到了 System.NullReferenceException 应用程序。我想我需要配置我的web.config以这样的方式让Spring.NET在IIS下工作。 Web.config文件是:

<结构>
< configSections>
    < sectionGroup名称=通用>
    <节名称=记录TYPE =Common.Logging.ConfigurationSectionHandler,Common.Logging/>
    < / sectionGroup>
    < sectionGroup NAME =春天里>
    <节名称=背景TYPE =Spring.Context.Support.WebContextHandler,Spring.Web/>
    <节名称=解析器TYPE =Spring.Context.Support.NamespaceParsersSectionHandler,Spring.Core/>
    < / sectionGroup>
    <节名称=databaseSettingsTYPE =System.Configuration.NameValueSectionHandler/>
< / configSections>
<普通>
    <&记录GT;
    < factoryAdapter TYPE =Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4Net>
        <精氨酸键=configTypeVALUE =FILE-WATCH/>
        <精氨酸键=CONFIGFILEVALUE =〜/配置/ Log4Net.xml/>
    < / factoryAdapter>
    < /记录>
< /&常见GT;
<春>
    <解析器/>
    <上下文中,GT;
    <资源URI =〜/ data.xml中/>
    <资源URI =〜/ web.xml文件/>
    < /背景>
< /春>
< databaseSettings>
    <添加键=db.datasource值=数据源= \\ SQLEX $ P $干燥综合征; AttachDbFilename = | DataDirectory目录| \\的ASPNETDB.mdf;集成安全=真;用户实例=真/>
< / databaseSettings>
<&的appSettings GT;
    <添加键=Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectNameVALUE =NHibernateSessionFactory/>
    <添加键=Telerik.SkinVALUE =夕阳/>
< /的appSettings>
<&是connectionStrings GT;
    <添加名称=ApplicationServices的connectionString =数据源= \\ SQLEX $ P $干燥综合征;集成安全性= SSPI; AttachDBFilename = | DataDirectory目录| \\ ASPNETDB.MDF;用户实例=真的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;
<&的System.Web GT;
    <编译调试=真targetFramework =4.0>
    <&集会GT;
        <添加组件=System.Design,版本= 4.0.0.0,文化=中性公钥= B03F5F7F11D50A3A/>
        <添加组件=System.Windows.Forms的,版本= 4.0.0.0,文化=中性公钥= B77A5C561934E089/>
        <添加组件=System.Speech,版本= 4.0.0.0,文化=中性公钥= 31BF3856AD364E35/>
    < /组件>
    < /编译>
    <身份验证模式=表格>
    <形式loginUrl =〜/页/为Login.aspx超时=2880defaultUrl =〜/页/抵押/ Home.aspx/>
    < /认证>
    <会员和GT;
    <供应商>
        <清/>
        <添加名称=AspNetSqlMembershipProviderTYPE =System.Web.Security.SqlMembershipProvider的connectionStringName =ApplicationServicesenablePasswordRetrieval =假enablePasswordReset设置=真requiresQuestionAndAnswer =假requiresUniqueEmail =假maxInvalidPasswordAttempts =5minRequiredPasswordLength =6minRequiredNonalphanumericCharacters =0passwordAttemptWindow =10的applicationName =//>
    < /供应商>
    < /会员>
    <型材>
    <供应商>
        <清/>
        <添加名称=AspNetSqlProfileProviderTYPE =System.Web.Profile.SqlProfileProvider的connectionStringName =ApplicationServices的applicationName =//>
    < /供应商>
    < / profile文件>
    < roleManager启用=false的>
    <供应商>
        <清/>
        <添加名称=AspNetSqlRoleProviderTYPE =System.Web.Security.SqlRoleProvider的connectionStringName =ApplicationServices的applicationName =//>
        <添加名称=AspNetWindowsTokenRoleProviderTYPE =System.Web.Security.WindowsTokenRoleProvider的applicationName =//>
    < /供应商>
    < / roleManager>
    <&的HttpModules GT;
    <添加名称=春TYPE =Spring.Context.Support.WebSupportModule,Spring.Web/>
    <添加名称=OpenSessionInViewTYPE =Spring.Data.NHibernate.Support.OpenSessionInViewModule,Spring.Data.NHibernate32/>
    < /&的HttpModules GT;
    <&HttpHandlers的GT;
    <添加动词=*路径=* ASPX。TYPE =Spring.Web.Support.PageHandlerFactory,Spring.Web/>
    <添加动词=*路径=* ASMX。TYPE =Spring.Web.Services.WebServiceHandlerFactory,Spring.Web/>
    <添加动词=*路径=ContextMonitor.ashxTYPE =Spring.Web.Support.ContextMonitor,Spring.Web/>
    <添加路径=Telerik.Web.UI.WebResource.axdTYPE =Telerik.Web.UI.WebResource动词=*确认=FALSE/>
    < / HttpHandlers的>
    <网页和GT;
    <控制与GT;
        <添加标签preFIX =春天命名空间=Spring.Web.UI.Controls集结号=Spring.Web/>
    < /控制>
    < /页>
< /system.web>
< system.webServer>
    <模块runAllManagedModulesForAllRequests =真/>
    <验证validateIntegratedModeConfiguration =FALSE/>
    <&处理GT;
    <添加名称=Telerik_Web_UI_WebResource_axd动词=*preCondition =integratedMode路径=Telerik.Web.UI.WebResource.axdTYPE =Telerik.Web.UI.WebResource/>
    < /处理器>
< /system.webServer>
<位置路径=安全>
    < system.webServer>
    < directoryBrowse启用=FALSE/>
    < /system.webServer>
< /地点>
< /结构>

我还有什么要补充。据pviously工作的罚款$ P $,但现在它给我的错误。你帮是AP preciated。


解决方案

的web.config 缺乏必要的配置部分,从文档:


  

Windows Server 2008上配置IIS 7.0的中,Win7和Windows
  Vista的


  
  

有一些配置特定于使用IIS7,该
  适当的code SNIPPIT在如下所示的web.config地方。


< system.webServer>
  <验证validateIntegratedModeConfiguration =FALSE/>
  <模块>
    <添加名称=春TYPE =Spring.Context.Support.WebSupportModule,Spring.Web/>
  < /模块>
  <&处理GT;
    <添加名称=SpringPageHandler动词=*路径=* ASPX。TYPE =Spring.Web.Support.PageHandlerFactory,Spring.Web/>
    <添加名称=SpringWebServiceHandler动词=*路径=* ASMX。TYPE =Spring.Web.Services.WebServiceHandlerFactory,Spring.Web/>
    <添加名称=SpringContextMonitor动词=*路径=ContextMonitor.ashxTYPE =Spring.Web.Support.ContextMonitor,Spring.Web/>
  < /处理器>
< /system.webServer>

http://www.springframework.net/doc-最新/参考/ HTML / web.html#d4e7051

I am using Spring.NET in my web application. At the beginning the application was set to use Visual Studio Development Server. Everything was working fine. But when I changed it to use Local IIS Web server and created a Virtual Directory and run the application I got System.NullReferenceException. I think I need to configure my Web.config in such a way so the Spring.NET work with IIS. The Web.config file is:

<configuration>
<configSections>
    <sectionGroup name="common">
    <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
    <sectionGroup name="spring">
    <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web" />
    <section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
    </sectionGroup>
    <section name="databaseSettings" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<common>
    <logging>
    <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
        <arg key="configType" value="FILE-WATCH" />
        <arg key="configFile" value="~/Config/Log4Net.xml" />
    </factoryAdapter>
    </logging>
</common>
<spring>
    <parsers />
    <context>
    <resource uri="~/Data.xml" />
    <resource uri="~/Web.xml" />
    </context>
</spring>
<databaseSettings>
    <add key="db.datasource" value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.mdf;Integrated Security=True;User Instance=True" />
</databaseSettings>
<appSettings>
    <add key="Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectName" value="NHibernateSessionFactory" />
    <add key="Telerik.Skin" value="Sunset"/>    
</appSettings>
<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
    <compilation debug="true" targetFramework="4.0">
    <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </assemblies>
    </compilation>
    <authentication mode="Forms">
    <forms loginUrl="~/Pages/Login.aspx" timeout="2880" defaultUrl="~/Pages/Secured/Home.aspx" />
    </authentication>
    <membership>
    <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
    </providers>
    </membership>
    <profile>
    <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
    </providers>
    </profile>
    <roleManager enabled="false">
    <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
    </providers>
    </roleManager>
    <httpModules>
    <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
    <add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate32" />
    </httpModules>
    <httpHandlers>
    <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web" />
    <add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web" />
    <add verb="*" path="ContextMonitor.ashx" type="Spring.Web.Support.ContextMonitor, Spring.Web" />
    <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
    </httpHandlers>
    <pages>
    <controls>
        <add tagPrefix="spring" namespace="Spring.Web.UI.Controls" assembly="Spring.Web" />
    </controls>
    </pages>
</system.web>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <validation validateIntegratedModeConfiguration="false" />  
    <handlers>
    <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />        
    </handlers>
</system.webServer>
<location path="Secured">   
    <system.webServer>
    <directoryBrowse enabled="false" />
    </system.webServer>
</location>
</configuration>

What else I have to add here. It was working fine previously but now it is giving me error. You help be appreciated.

解决方案

Your web.config lacks parts of the required configuration, from the docs:

Configuration for IIS 7.0 on Windows Server 2008, Win7 and Windows Vista

There is some configuration that is specific to using IIS7, the appropriate code snippit to place in web.config shown below.

<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
    <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
  </modules>
  <handlers>
    <add name="SpringPageHandler" verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
    <add name="SpringWebServiceHandler" verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web" />
    <add name="SpringContextMonitor" verb="*" path="ContextMonitor.ashx" type="Spring.Web.Support.ContextMonitor, Spring.Web"/>
  </handlers>
</system.webServer>

http://www.springframework.net/doc-latest/reference/html/web.html#d4e7051

这篇关于IIS服务器和Spring.NET对象实例化失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆