0

I'm trying to setup an ASP.Net 4 website with Spring.net 1.3.2.

For basic pages, Spring loads the pages without problems and injects the dependencies alright. On some pages however I get a NullReferenceException between the ctor and the Page_Load, with the following information:

Message:

Value cannot be null.
Parameter name: methodInfoDeclaration

Stack trace:

   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)

On one page I narrowed it to a problem with a SiteMapDataSource, once I comment it the exception disappears. The exception still appears on other pages however.

I found people with similar errors elsewhere: http://forum.springframework.net/showthread.php?6621-Spring.NET-ASP.NET-4.0-Error

The associated bug has been fixed in version 1.3.1 however.

Here are the relevant parts of my 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>

And my object definition:

<object type="Default.aspx">
    <property name="TestProperty" value="Spring injected" />
</object>

Can somebody tell me how to avoid this exception ?

Mathieu Garstecki
  • 1,589
  • 1
  • 13
  • 18

1 Answers1

1

It was a version mismatch between two Spring assemblies. One of my colleagues referenced Spring.Core through NuGet while I referenced Spring.Web through a manually downloaded distribution.

Referencing both assemblies from the same source solved the problem.

Mathieu Garstecki
  • 1,589
  • 1
  • 13
  • 18