ASP.NET MVC 4 breaks ASP.NET MVC 3 projects - visual-studio-2010

After installing the ASP.NET MVC 4 Developer Preview, I can no longer open MVC 3 projects, with the following error message:
The project type is not supported by this installation.
<ProjectTypeGuids> in my MVC 3 .csproj file looks right:
<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Is this a bug in the MVC 4 developer preview, or is something missing from my Visual Studio 2010 install? And how do I solve it? Should I rollback my MVC 4 install?
I have tried running devenv /ResetSkipPkgs and installed MVC 3 Tools Update, to no avail.

"" If you want to update your projects to MVC4, and open them as such in the visual studio, then ""
The solution is to change the projectType guids from
{E53F8FEA-EAE0-44A6-8774-FFD645390401}
to
{E3E379DF-F4C6-4180-9B81-6769533ABE47}
in the csproj file, after you install the mvc4 visual studio package.

ASP.NET MVC 4 Developer Preview runs side by side with previous versions of ASP.NET MVC, however there are a few known issues to be aware of. The biggest one:
Installing ASP.NET MVC 4 Developer Preview breaks ASP.NET MVC 3 RTM
applications. ASP.NET MVC 3 applications that were created with the
RTM release (not with the ASP.NET MVC 3 Tools Update release) require
the following changes in order to work side-by-side with ASP.NET MVC 4
Developer Preview. Building the project without making these updates
results in compilation errors.
You'll find the solutions here.

I was searching for a different issue and stumbled across this question, It is similar to a few I answered and figured I would post them here:
ModelClientValidationRule conflict
Build Errors - 'System.Web.Mvc.ModelClientValidationRule' Conflicts

Check the reference to System.Web.Mvc.dll file in your reference. Make sure its pointing to C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll
If its pointing to the one under ASP.NET MVC 4 directory then open your project file in a notepad. Look for
<Reference Include="System.Web.Mvc">
<Private>False</Private>
</Reference>
This should be changed to
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL" />

Related

Razor View Page cannot be added as a new Item - Visual Studio 2010

Background:
I used to have VS2010 Professional. Upgraded to VS2010 Ultimate. Installed SP1. Installed MVC3, MVC3 Tools Update
I'm currently working on some custom Orchard modules, and for some reason, I don't see Razor as an installed template. But if I fire up a new ASP.NET MVC3 app, I see it. Has anyone ran into this issue. I've tried uninstalling MVC3 and Tools Update. No luck. Is there something obvious I'm missing?
MVC3 app - as you can see MVC3 View Page (Razor) is available...
From an Orchard Module:
Have you tried to install the Razor engine as a NuGet Package for this solution? Open Package Manager Console (View - Other windows) and enter
Install-Package RazorEngine
Is the System.Web.Mvc.dll included in the references?
For me editing the project file and adding the value {E3E379DF-F4C6-4180-9B81-6769533ABE47} in front of the others guid's for <projecttypeguids> solved the problem.

System.Web.Mvc missing error while building ASP.NET MVC 3 using NAnt

My MVC 3 project is building successfully in my development machine with Visual Studio 2010 + MVC 3. In the build server, VS2010 is not used and I've installed 'ASP.NET MVC 3 Tools Update'. I've also downloaded NAnt and used TortoiseSVN to checkout all the files except bin directories.
But while building using Nant default.build, I'm getting build error
'The type or namespace name 'Mvc' does not exist in the namespace
'System.Web'
(are you missing an assembly reference?). Same with 'Controller', 'ActionResult', 'GlobalFilterCollection' etc (type or namespace could not be found).
I can see System.Web.Mvc.dll in
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\
. What am I missing here? Why NAnt can't find this file? Is there no other way than copying the assembly files into local bin?
I had the same issue and wasn't able to locate the System.Web.MVC reference assembly.
Finally found out and it was located inside the following location.
Note if your VS was installed in C: (Sometimes the MVC is not in the defaul location which everybody talk about, i mean the "Reference Assemblies" folder located in the C: drive.
if its not there, it should definitely be in here:
Program files(x86) --> Microsoft ASP.NET --> ASP.NET MVC 2 --> Assemblies System.Web.Mvc.dll
Hope this one is helpful.
Here is my answer -
Best way is to use NuGet package manager.
Just update the below MVC package and it should work
Why is System.Web.Mvc not listed in Add References?
If you use NuGet packages, you need to update MVC package. This worked for me.
If you Installed MVC Package from NuGet packages. simply uninstall package and install it again.
It's work for me
Which version of msbuild are you using to build the web project?
Is the web project referencing a specific version of or file path to System.Web.Mvc.dll?
Download and install ASP.NET MVC 3:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=4211
According to: http://weblogs.asp.net/scottgu/archive/2011/05/03/asp-net-mvc-3-tools-update.aspx
"The ASP.NET MVC 3 Tools update only includes Visual Studio tooling improvements and default project template changes – it does not include any changes to the ASP.NET MVC 3 runtime binaries."

Open an exising MVC 3 project in visual studio 11 developer preview

I've trying to open and convert an existing vs 2010 mvc 3 project in the new dev 11 preview and am running in to a difficult issue. The solution file will convert successfully, however the one mvc 3 web project in the solution shows in the solution explorer as unloaded post conversion. When i attempt to reload the project from solution explorer, i get prompted to convert the project and receive the following error in the upgradelog.xml
The project file'myproject.csproj' cannot be opened. There is a missing project subtype. Subtype: '{E53F8FEA-EAE0-44A6-8774-FFD645390401}' is unsupported by this installation.
From what i could track down, this has to do with MVC, but that doesn't really help me work around the issue. Any suggestions or workarounds would be appreciated.
Update: Actually, MVC 3 for Visual Studio 11 Dev Preview has just been published: http://www.microsoft.com/download/en/details.aspx?id=1491
We have not yet shipped MVC 3 support in Visual Studio 11. You can work around this by editing your csproj file and removing the project type GUID {E53F8FEA-EAE0-44A6-8774-FFD645390401}. This will cause your project to load like a normal WAP. You will be able to edit your code, however MVC-specific actions (Add Controller, etc) will not be available.
You may want to try the steps from the Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4 section of the release notes, even if the document describes the VS2010 version.
I managed to convert a VS2010/MVC3 project, but VS11 shows a warning every time I open the solution, stating that the project requires ASP.NET Web pages with Razor syntx 1.0. OTOH, the project seems to run without any problems (VS11 setup also installed ASP.NET Web pages 2).

I'm upgraded my project to Razor view engine, but VS2010 still auto-generates WebForms

I have upgraded to MVC3 and Razor, everything works fine. However, in my return View(model); the "View" is red and VS2010 will helpfully suggest I generate a view. When I do, it generates a aspx/WebForms view. There's no other aspx files in the project, and if I run the project, the Razor view engine works fine. There's obviously a setting somewhere that tells VS2010 which to default to, I can't find it. Any suggestions?
These are not explicit answer but rather a list of actions that you could try..
In the csproj file of your project make sure that the <ProjectGuidType> are set to <ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Try changing the ProjectGuid to some other Guid (last post). You will need to update the sln file or simply recreate the solution.
Not sure what method you used to upgrade, but have a look at the MVC 3 Upgrade Tool from CodePlex
If you can create a new ASP.NET MVC 3 project and add a Razor view as expected then the project where you are seeing this behavior is missing the ASP.NET MVC 3 project type guid, which you can find in a new ASP.NET MVC 3 project's .csproj file. If you can't do this than you should try reinstalling the ASP.NET MVC 3 Tools Update.

Add MVC3 as a Prerequisite in a WebApp installer project

How do I add Asp.NET MVC3 as a Prerequisite in my Visual Studio Installer project?
Just a side note, you don't need MVC 3 to be installed on the host that you use. You just need to do it like we did back in the "old" days.
Check out this blog post by ScottGu on "Running an ASP.NET MVC 3 app on a web server that doesn’t have ASP.NET MVC 3 installed".
You will need to write a custom before install step where you would manually check if the required assemblies have been installed. You may also check the following article on MSDN.
Actually, I'm gonna add another answer to address the question directly.
All you have to do is set "Copy Local = True" for the following referenced assemblies in your project:
Microsoft.Web.Infrastructure
System.Web.Helpers
System.Web.Mvc
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
And the setup project will automatically add them as "project dependencies" and put them into the "bin" folder when the setup is run.

Resources