[SPRNET-1473] A call to SpringMvcDependencyResolver GetServices fails with a cast exception (DictionaryEntry -> Implementation) Created: 05/Oct/11  Updated: 13/Dec/11  Resolved: 07/Oct/11

Status: Resolved
Project: Spring.NET
Component/s: Spring-NET-WEBMVC
Affects Version/s: 1.3.2
Fix Version/s: 2.0 M1

Type: Bug Priority: Major
Reporter: Andreas Kluth Assignee: Steve Bohlen
Resolution: Fixed Votes: 0
Labels: mvc
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In SpringMvcDependencyResolver the method:

public IEnumerable<object> GetServices(Type serviceType)

will always fail.

Instead of returning an object of the class asked for, it returns an DictionaryEntry, so instead of

91: var services = ApplicationContext.GetObjectsOfType(serviceType);
92: return services.Cast<object>();

it should be

91: var services = ApplicationContext.GetObjectsOfType(serviceType);
92: return services.Values.Cast<object>();

The issue was discovered here:
http://stackoverflow.com/questions/7598279/how-to-do-spring-net-di-injection-in-action-filters-asp-net-mvc-3/



 Comments   
Comment by Steve Bohlen [ 05/Oct/11 ]

Yep, that's most definitely the WRONG code. Thanks for finding + reporting this – we'll fix it ASAP.

Comment by Steve Bohlen [ 07/Oct/11 ]

corrected improper return type from SpringMvcDependencyResolver.GetServices(...) call.

Comment by Shane Walters [ 13/Dec/11 ]

I think a 1.3.2 hotfix should be issued with this fix in it. I banged my head against this for hours today. Any first-time spring user with MVC3 is going to have a very hard time with this.

Generated at Wed Oct 23 00:46:24 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.