Question

I have an older asp.net mvc solution (s#arp framework) whith two projects one for web and one for controller. I have changed the dll to the latest versions (2.0) for System.Web.MVC and Microsoft.Web.MVC. I have also adjusted my Web.Config:

<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

Is this (in theory) all I have to do?

The solution builds fine but I get this error:

Attempted to access an element as a type incompatible with the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.

Source Error:

Line 32: Line 33: ViewEngines.Engines.Clear(); Line 34: ViewEngines.Engines.Add(new AreaViewEngine()); Line 35: Line 36: ModelBinders.Binders.DefaultBinder = new SharpModelBinder();

This might not be related to the mvc switch but the s#arp framework. Any ideas? Thanks.

Best wishes,

Christian

Was it helpful?

Solution

This issue is related to S#arp Architecture. You'll need to get the MVC2 version of S#arp here: http://github.com/codai/Sharp-Architecture/downloads. The first item on the list is what you want, including the VS2010 template. (Note the typo in the description that says ASP.NET 2, should be ASP.NET MVC 2)

Hope that helps.

P.S. If you're curious about the cause of the exception itself, check out this brief article: http://dotnetperls.com/arraytypemismatchexception. I suspect (without looking at S#arp 1 and MVC2 source) that the SharpModelBinder (the MVC1 version) is now incompatible with the MVC2 implementation of the MVC DefaultBinder, and this isn't caught at compile-time because SharpModelBinder inherits from DefaultBinder and the compiler thinks all is well. It's only at runtime that the acual incompatability is detected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top