我想用Spring.net 1.3.2安裝一個ASP.Net 4網站。爲什麼使用Spring.net加載ASPX頁面時會出現NullReferenceException異常?
對於基本頁面,Spring加載沒有問題的頁面並注入依賴關係。 在某些頁面,但是我得到的構造函數和Page_Load中之間一個NullReferenceException,包含以下信息:
消息:
Value cannot be null.
Parameter name: methodInfoDeclaration
堆棧跟蹤:
at System.Reflection.Emit.TypeBuilder.DefineMethodOverrideNoLock(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
at System.Reflection.Emit.TypeBuilder.DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
at Spring.Proxy.AbstractProxyMethodBuilder.BuildProxyMethod(MethodInfo method, MethodInfo interfaceMethod) in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Proxy\AbstractProxyMethodBuilder.cs:line 107
at Spring.Web.Support.SupportsWebDependencyInjectionTypeBuilder.BuildProxyType()
at Spring.Web.Support.InterceptControlCollectionStrategy.GetInterceptedCollectionType(Type controlCollectionType, InjectDependenciesCallbackHandler staticCallback)
at Spring.Web.Support.InterceptControlCollectionStrategy.GetInterceptedCollectionFactory(Type ownerType, Type collectionType)
at Spring.Web.Support.InterceptControlCollectionStrategy.InterceptCollection(Control owner, ControlCollection originalCollection)
at Spring.Web.Support.InterceptControlCollectionStrategy.Intercept(IApplicationContext defaultApplicationContext, ControlAccessor ctlAccessor, ControlCollectionAccessor ctlColAccessor)
在一個頁面上我縮小它到SiteMapDataSource
的問題,一旦我評論它,異常消失。但是,其他頁面上仍然會出現異常。
我發現其他地方的類似錯誤的人:http://forum.springframework.net/showthread.php?6621-Spring.NET-ASP.NET-4.0-Error
相關的錯誤已被固定在1.3.1版本不過。
這裏是我的Web.config文件中的相關部分:
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
</sectionGroup>
[...]
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web" />
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
我的對象定義:
<object type="Default.aspx">
<property name="TestProperty" value="Spring injected" />
</object>
有人可以告訴我如何避免這種例外?