简体   繁体   中英

MVC version mismatch with NuGet in Visual Studio 2010 on XP

I went to do this tutorial: http://mono.servicestack.net/ServiceStack.Hello/

I am running on XP, SP3, Visual Studio 2010, SP1. The first PM downloaded, built, ran. In the package manager:

PM> Install-Package ServiceStack.Host.AspNet

The second PM downloaded just fine:

Install-Package ServiceStack.Host.Mvc

The error was that there was no reference for:

using System.Web.Mvc;

So I added a reference to my version of System.Web.Mvc, and then got this error:

Error   1   Assembly 'ServiceStack.Mvc, Version=4.0.11.0, Culture=neutral, 
PublicKeyToken=null' uses 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 
'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
c:\Documents and Settings\daniel.SUN\My Documents\Visual Studio 2010\Projects\RestTestApi
\packages\ServiceStack.Mvc.4.0.11\lib\net40\ServiceStack.Mvc.dll    RestTestApi

Clearly I have a version mismatch in .Net and MVC but I'm not sure how to navigate through to resolving this. I have a kind of old system, XP SP3. I put .NET 4.0, which I checked was compatible with this OS. But I have older versions of .NET as well that I never uninstalled. The question is what should be installed for this error to be resolved? I installed MVC 4 and then it built, but didn't run. Here is a list from "Add or Remove Programs":

Microsoft .NET Framework 2.0 Service Pack 2
Microsoft .NET Framework 3.0 Service Pack 2
Microsoft .NET Framework 3.5 SP1
Microsoft .NET Framework 4 Client Profile
Microsoft .NET Framework 4 Extended
Microsoft .NET Framework 4 Multi-Targeting Pack
Microsoft ASP.NET MVC 2
Microsoft ASP.NET MVC 2 - Visual Studio 2010 tools
Microsoft ASP.NET MVC 4
Microsoft ASP.NET Web Pages 2

The failure on run was in the browser upon running: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 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.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I then tried to install MVC 3, but it would not, giving some error about NuGet being a newer version. So it all comes back to the right set of versions?

I solved this by uninstalling MVC4 and installing MVC3. For some reason I thought with .NET 4.0 that I should use MVC4, as though they were a pair. It looks like that thinking was wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM