I am new to new to .Net. I have to upgrade my application from .Net 3.5 to .Net 4.5. This application uses spring.net with nHibernate. I am getting null reference error right on the first page of the application while executing the below command because I am referencing PersonDao and it is not initialized. My question is the object PersonDao should have been initialized based on the webconfig and Dao files mentioned below but its not want to know the reason for the same.
_personDao = (IPersonDao)this.ApplicationContext.GetObject("PersonDao");
I have kept the code as same, as part of upgrade I have just modified the web config files and upgraded the spring.net and nhibernate dlls used. I have tried various permutations and combination in the web config files and in the versions of spring.net and nhiberbate but without any success. Below are the web config files
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<section name="databaseSettings" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<system.web.extensions>
<scripting>
<webServices>
<authenticationService enabled="true" requireSSL="true"/>
</webServices>
</scripting>
</system.web.extensions>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE"/>
<arg key="configFile" value="~/Config/Log4Net.xml"/>
</factoryAdapter>
</logging>
</common>
<log4net>
<appender name="NHibernateFileLog" type="log4net.Appender.RollingFileAppender">
<file value="Logs/nhibernate.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="100MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
<file value="Logs/general.txt"/>
<appendToFile value="true"/>
<maximumFileSize value="100MB"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="5"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<level value="ERROR"/>
<appender-ref ref="GeneralLog"/>
</root>
<logger name="SSA.Core" additivity="false">
<level value="ERROR"/>
<appender-ref ref="NHibernateFileLog"/>
</logger>
<logger name="NHibernate" additivity="false">
<level value="ERROR"/>
<appender-ref ref="NHibernateFileLog"/>
</logger>
</log4net>
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/>
</parsers>
<context>
<resource uri="config://spring/objects"/>
<resource uri="~/Config/Web.xml"/>
<resource uri="~/Config/Dao.xml"/>
<resource uri="~/Config/Services.xml"/>
</context>
</spring>
<appSettings>
<add key="DEFAULT_CLIENT_ID" value="1"/>
<add key="Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectName" value="SessionFactory"/>
<add key="hibernate.show_sql" value="true"/>
<add key="hibernate.connection.provider" value ="NHibernate.Connection.DriverConnectionProvider"/>
</appSettings>
<connectionStrings/>
<system.web>
<xhtmlConformance mode="Transitional"/>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
<add verb="*" path="ContextMonitor.ashx" type="Spring.Web.Support.ContextMonitor, Spring.Web" validate="true"/>
<add verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<remove verb="*" path="*.asmx"/>
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate32"/>
</httpModules>
<httpRuntime maxRequestLength="1048576" executionTimeout="50000"/>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms name=".SSACOOKIE" loginUrl="~/Web/Login.aspx" />
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<customErrors mode="Off" defaultRedirect="~/Web/Error.aspx">
</customErrors>
<pages theme="Company" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="ajaxtools" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
<add tagPrefix="spring" namespace="Spring.Web.UI.Controls" assembly="Spring.Web"/>
</controls>
</pages>
</system.web>
<databaseSettings>
<add key="db.server" value="*********"/>
<add key="db.user" value="*********"/>
<add key="db.password" value="*******"/>
<add key="db.schema" value="**********"/>
</databaseSettings>
<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="SpringContextMonitor" verb="*" path ="ContextMonitor.ashx" type ="Spring.Web.Support.ContextMonitor, Spring.Web"/>
</handlers>-->
</system.webServer>
<runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Spring.Core" publicKeyToken="65E474D141E25E07" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.2.40943" newVersion="1.3.2.40943"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Spring.Aop" publicKeyToken="65E474D141E25E07" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.2.40943" newVersion="1.3.2.40943"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Spring.Data" publicKeyToken="65E474D141E25E07" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.2.40943" newVersion="1.3.2.40943"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database"
xmlns:tx="http://www.springframework.net/tx">
<description>
The SSA object definitions for the Data Access Objects.
</description>
<object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
<property name="ConfigSections" value="databaseSettings"/>
</object>
<!-- Database and NHibernate Configuration -->
<db:provider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Integrated Security=false;Server=${db.server};User ID=${db.user};PWD=${db.password};initial catalog=${db.schema};FailIfMissing=True;"/>
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate32">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingAssemblies">
<list>
<value>SSA.Core</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="hibernate.default_schema" value="*****"/>
<entry key="hibernate.dialect" value="NHibernate.Dialect.MsSql2008Dialect"/>
<entry key="hibernate.connection.isolation" value="ReadUncommitted"/>
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
</dictionary>
</property>
<property name="ExposeTransactionAwareSessionFactory" value="true" />
</object>
<tx:attribute-driven />
<object id="transactionManager" type="Spring.Data.TxScopeTransactionManager, Spring.Data.NHibernate32">
<property name="DbProvider" ref="DbProvider"/>
<property name="SessionFactory" ref="SessionFactory"/>
<property name="NestedTransactionsAllowed" value="true"/>
</object>
<!-- Exception translation object post processor --><!--
<object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>-->
<object id="HibernateTemplate" type="Spring.Data.NHibernate.Generic.HibernateTemplate">
<property name="SessionFactory" ref="SessionFactory" />
<property name="TemplateFlushMode" value="Auto" />
<property name="CacheQueries" value="true" />
</object>
<!-- Data Access Objects -->
<object id="ClientDao" type="SSA.Core.Dao.NHibernate.ClientDao, SSA.Core">
<property name="HibernateTemplate" ref="HibernateTemplate"/>
</object>
<object id="ApplicationDao" type="SSA.Core.Dao.NHibernate.ApplicationDao, SSA.Core">
<property name="HibernateTemplate" ref="HibernateTemplate"/>
</object>
<object id="ApplicationUserDao" type="SSA.Core.Dao.NHibernate.ApplicationUserDao, SSA.Core">
<property name="HibernateTemplate" ref="HibernateTemplate"/>
</object>
<object id="PersonDao" type="SSA.Core.Dao.NHibernate.PersonDao, SSA.Core">
<property name="HibernateTemplate" ref="HibernateTemplate"/>
</object>
.
.
.
.
<object id="CaseDao" type="SSA.Core.Dao.NHibernate.CaseDao, SSA.Core">
<property name="HibernateTemplate" ref="HibernateTemplate"/>
</object>
</objects>
</Dao.XML>
The 'httpHandlers' and 'httpModules' components were not working as expected while migrating from 'IIS 6.0' to 'IIS 7.0 pipeline mode - Integrated' which was causing the problem.