0

我正在尝试使用 Spring.net 1.3.2 设置一个 ASP.Net 4 网站。

对于基本页面,Spring 加载页面没有问题并注入依赖项。但是,在某些页面上,我在 ctor 和 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>

有人能告诉我如何避免这个例外吗?

4

1 回答 1

1

这是两个 Spring 程序集之间的版本不匹配。我的一位同事通过 NuGet 引用了 Spring.Core,而我通过手动下载的发行版引用了 Spring.Web。

引用来自同一来源的两个程序集解决了这个问题。

于 2012-05-03T14:14:14.977 回答