I keep on getting: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'
I have installed MVC3 and MS .Net Framework 4 and want to upgrade a solution that was written in MVC1 and upgraded to MVC2. I would now like to upgrade to MVC3 but keep on getting the above error. I suspect that it is the reference that I have to System.web, if I view the properties of it in VS2010 I can see that it is still pointing to Version 2.0
I delete the reference and add a new one to the system.web.dll in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 but when I right click on the reference in VS2010 solution explorer to view the properties it still points to the version 2 in C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll
I did add the something new to VS2010, I think it was a Powertools pack and adding the reference looks different, could it be that? I did add the ref to the new system.web.mvc dll and that shows correctly. Just as a note, I did the upgrade by hand as per the MS notes and tried the upgrade tool.
Try following the upgrade steps. Also there's a project upgrade tool you may checkout.
The documentation was solid on the upgrade. The problem was with the Powertools and once I un-installed it I could add the reference again.
Related
I have some annyoing problem which I can't figure out. I installed Visual Studio 2017 Community on a new laptop and loaded an project I made on my old one from TFS. Suddenly some of the references can't get resolved.
So I tried to create a complete fresh ASP.NET MVC Project and download some of the assemblies that don't work in the old project by NUGET. After downloading the references don't work. I get already the warning in VS. One of those assemblies that doesn't work is for example
The referenced component 'System.Linq.Expressions' could not be found.
NUGET downloaded the assembly correctly and added the reference to the project. If I open the project file I find the entry for System.Linq.Expressions
and in HintPath: ..\packages\System.Linq.Expressions.4.3.0\lib\net463.
That file definitely exists on the file system. I also tried to change to path to an absolute one manually with same result.
I am using the newest .NET framework 4.7.2
Any suggestions what might be the problem?
I've created a new project in Visual Studio 2013.2 with WebAPI and MVC enabled. Right out of the box, compiling the generated project and running gives me the exception. Looking around here, I've come across the following two questions:
Mvc 5.1 MissingMethodException System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached
Both these answers involve assembly redirects; however, in my case the assembly redirects are present and I'm still getting an issue. My problem is that the GAC is loading version 3.00.11001.0 which is listed under assembly version 3.0.0.0 and my application wants 3.20.20520.0 which is also listed as assembly version 3.0.0.0. (Note that in diagnosing the project I installed the 5.2 pre-release nuget package, but I had the same problem with the original versions, I just don't have those readily available)
Since the GAC is preferred over the bin directory, it seems that my development machine will always pull the wrong file.
Is it safe to remove these files from the GAC? It appears that these are required for Visual Studio to produce Razor intellisense
Removing the Assemblies from the GAC did behave exactly as expected. The Razor intellisense for the project stopped working; however, the application began functioning properly.
You have to add the reference of System.Web to get it working.
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."
So I'm trying to take a VS2008 MVC1 project to MVC3.
Here are the steps I'm trying to do.
Use conversion to to convert vs2008 mvc1 to vs 2008 mvc2 (success)
Tool: http://weblogs.asp.net/leftslipper/archive/2010/03/10/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2-rtm.aspx
Open vs2008 sln in vs2010 to convert (failed on my main app project)
Convert from .Net3.5 to .Net 4.0
Use tool to covert to MVC3
On step two, it fails on my main project, and then will not open the project with the error.
The Project <project path> cannot be opened
The project type is not supported by this installation
I found some StackOverflow posts abotu similar issue with RC1 and RC2, but installaed my MVC2 from the webplatform installer and so it should eb the latest, not the RC.
I assume this line is my problme, anyone know how to fix it?
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
I tried posting my csproj, but it excedded the max lines.. if there is a part neede to diagnose this just let me know.
Thanks,
Cal-
Personally I use the following migration path *:
Ensure that I have ASP.NET MVC 3 RTM Tools Update installed
Open the ASP.NET MVC 1.0 project in Visual Studio 2010
The migration wizard kicks in and asks me if I want to convert to .NET 4.0 and I say Yes
Make sure that the System.Web.Mvc assembly referenced in my project is V2.0.0.0. If it is still the old I remove it and add the correct version
At this stage I ensure that I have a working ASP.NET MVC 2.0 application and close Visual Studio.
There is one final step left. For it, depending on my mood, I do one of the following:
Do the migration manually by following the upgrade guide
Use the ASP.NET MVC 3 Project Upgrade Tool
* To answer this question I did the previous steps on a real ASP.NET MVC 1.0 project and it was successfully upgraded to ASP.NET MVC 3
Okay I did it both ways and got the same result.
I did figure it out, here's what was going on. Be aware that steps 1 and 3 are probably all that's needed to fix it, but I'm including step two, both for clarity of my debugging process and completeness in case it's required and my assumptions are false.
Even though MVC# was installed, and showed as installed in the Add removed programs, MVC 3 was not showing up as a reference. I unininstalled, reinstalled and rebooted and it started showing up.
I had to modify the project Type Guids in he CSPROJ file, first I deleted them one at a time till the Main app project was able to load, then I recovnerted. All projects except the main one worked, but it didnt' convert. It did not covnert becuase of an unrecognized project Type Guid.
Becasue it didnt convert I got this error:
The type 'System.Web.Mvc.ViewMasterPage' is ambiguous: it could come from assembly 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' or from assembly 'C:\Windows\assembly\GAC_MSIL\System.Web.Mvc\1.0.
Note the Coverted did not throw and error, it merely logged that the project did not get convereted. You have to look at the logs carefully to notice.
Luckily you can run the converter on the same soloution multiple times. that's how I noticed this.
I had to modify the Project Type guids again, because of the unrecognized type guid again. I just created a new MVC3 project and edited the CSPROJ to get the correct type guids.
{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
Note: this is what the guids already looked like, but I copied them from an existing good project and pasted them in the file and it started working, my best guess is there was an invisible character put in there by the conversion process.
After this I reconverted and it worked perfectly, and the errors went away.
Thanks,
Cal-
I want to learn to use Fluent NHibernate, and I'm working in VS2010 Beta2, compiling against .NET 4, but I'm experiencing some problems.
Summary
My main problem (at the moment) is that the namespace FluentNHibernate isn't available even though I've imported all the .dll assemblies mentioned in this guide.
This is what I've done:
1. I downloaded the Fluent NHibernate source from here, extracted the .zip and opened the solution in VS. A dialog asked me if I wanted to convert the solution to a VS2010 solution, so I did.
2. I then went into each project's properties and configured all of them to compile for .NET 4, and built the entire solution.
3. I copied all the .dll files from /bin/Debug/ in the FluentNHibernate to a new folder on my local hard drive.
4. In my example project, I referenced FluentNHibernate.dll and NHibernate.dll from the new folder.
This is my problem:
If I right-click on FluentNHibernate in the References list and select "View in Object Browser...", it shows up correctly.
Now, when I try to create a mapping class, I can't import FluentNHibernate. This code:
using FluentNHibernate.Mapping;
namespace FluentNHExample.Mappings
{
}
generates an error on the using statement, saying
The type or namespace 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?).
The FluentNHibernate assembly is still in the list of References of my project, but if I try to browse the assembly in Object Browser again, it can't be found.
What is causing this?
I also had similar problem.
"Error List" window displayed:
The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?)
But "Output" window was displaying detailed information:
warning MSB3253: The referenced assembly "FluentNHibernate" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
In my case; I had created a console application project which was targeting ".Net Framework 4 Client Profile" by default, so changing to ".Net Framework 4" fixed issue for me.
I'm unable to observe this behavior in my build, could it be related to this problem: Weird override problem with Fluent NHibernate and .NET 4
If so you could try http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/ae4013d711d2e4ad as a potential fix.
Isn't there a better way to fix this problem?
I don't want to reference System.Data.OracleClient. So I shouldn't have to target the full .Net framework if I don't even want that reference.
Can't I target the Client Profile of the .Net framework, but add a compiler warning exception somewhere so that it just skips that warning? I know it won't cause a runtime problem because I don't use Oracle.
I get identical problem which says there's also a dependency on System.Web. Same story, this is for a Windows WPF app, so I don't need System.Web. Can't I just target the Client Profile and somehow convince the compiler to keep going?
Thanks,
Hugh
EDIT: I figured this out! I had to compile NHibernate myself though. Opened the 2.1.2 code in Visual Studio and deleted everything that says "Oracle" or "System.Web" and I ended up getting it to build. I do not have to target the full .Net Framework now.
We had this issue and the issue went away if we removed the obj and bin folder from the project which was referencing the NHibernate using project.
So we have 'project1' which uses NHibernate to produce project1.dll.
'project2' references project1.dll.
Problem resolved if we removed the obj/bin folder from project2.
Can't say why, but our solution now compiles fine.
Mike.