Type mismatch after installing MVC 3 in a MVC 2 view
HI All,
after installing ASP.NET MVC 3 and opening my current MVC 2 project all seemed to be fine. But when opening a view which uses System.Web.MVC.SelectList I get the following error:
Error 205 Value of type 'System.Web.Mvc.SelectList' cannot be converted to 'System.Web.Mvc.SelectList'. Type mismatch could be due to mixing a file reference to 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll' in project 'DSMStoreFront' with a file reference to 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\开发者_StackOverflow社区System.Web.Mvc.dll' in project '2_Views_Basket_Overview.aspx'. If both assemblies are identical, try replacing these references so both references are from the same location.
When debugging the whole project nothing else happens so I just think this is a small issue in the editor of MVC-views. But maybe someone knows a solution to fix it?
All references are targeted at MVC 2 and the two web.configs (root & views-folder) owe the following reference:
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Many thanks in advance!
If you've installed MVC3 are you looking to use it for this project or did you want to stick with MVC2 for now? Are you using IIS6 by chance with any script maps? Also I remember that MVC3 is for .NET 4.0 exclusively, is your app using.NET 4.0 or 3.5? I've not had the problem you're running into specifically so I'm just throwing out some ideas. Maybe try doing a quick search of your project contents or the project file itself for any references that point to 3, that shouldn't be if you're trying to stick with MVC2.
If you're wanting to upgrade to 3.0 you'll have to add the following to your web.config.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Alternatively, I wonder if you can modify that assembly mapping to redirect requests for 3.0 to map back to 2.0?
精彩评论