views:

60

answers:

1

Hi,

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

+2  A: 

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.

Brandon Satrom
Brandon would be correct.
Alec Whittington
Hi, I am almost there. I exchanged all the dlls in the lib folder with those of a later version of s#arp. then made sure that all dlls in the solution point to the latest one (e.g. there is only one sharparch dll now). Everything compiles and the site runs but the mvc contrib grid causes some problems now - the reason why i wanted to switch to mvc 2.0 in the first place ...
csetzkorn
Did you figure out the MvcContrib Grid issue? If not, did you post another question here? If not, there's a lot of MvcGrid folks on SO who would be happy to help.
Brandon Satrom
I did not update the web.config in the view folder of s#arp to version 2.0. after this verything worked fine.
csetzkorn