The type or namespace name 'ViewPage' does not exist in the namespace 'System.Web.Mvc' - asp.net

I have a solution (VisualStudi0 2013) that worked perfectly well until couple of days ago. Suddenly after I had restarted my computer I started getting the following error locally everytime I run the debugger. There are no errors in the solution itself but only in the browser. I'm able to clean, build, rebuild and publish the solution without any problems. In fact the solution works well on-line but not locally on my computer.
Another fact is that the aspx files are debugged without any error. It's only the pages that are served with MVC that throws this error.
I searched for the ViewPage and it only exists in the web.config.
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXX"
I'm certain that the ViewPage is available in the solution references under the 'System.Web.Mvc' but why I'm getting this error in a file in the Temporary ASP.NET Files. I cleared the temp files but it didn't help.
Compiler Error Message: CS0234: The type or namespace name 'ViewPage' does not
exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)
Source Error:
Line 136: public class views_home_index_aspx : global::System.Web.Mvc.ViewPage, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\6f597118\63e8eef9\App_Web_index.aspx.a8d08dba.6ujukvge.0.cs Line: 136

That was caused by a Security Update. I fixed it by setting CopyLocal to true on the System.Web.Mvc reference but you can get more details at http://blogs.msdn.com/b/webdev/archive/2014/10/16/microsoft-asp-net-mvc-security-update-broke-my-build.aspx

Related

CS0234: Missing Assembly Reference

I have some missing assemblies in my PC, and don't have any idea how to fix it.
When I create a new ASP.NET MVC 4 internet application from template (using VS 2012) everything works fine. As soon as I try to integrate Web API controller I get a missing assembly reference error. For example, when I create application using ASP.NET 4 Web API default template and click "API" on the interface I get Compilation error:
Compiler Error Message: CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
I have checked the assembly and everything seems to be fine. It's in version 4.0. I have .NET framework 4.5 installed on my PC. Where should I look for the reason of the issue?
I saw this same error code (different missing reference) when compiling a PCL using msbuild but not when building via Visual Studio:
error CS0234: The type or namespace name 'Storage' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
In my case it was caused by a 'using Windows.Storage;' statement that was not actually referenced by any code in the file. I removed the line and the error was fixed.

error CS0246: The type or namespace name 'TModel' could not be found

I'm trying to publish a MVC4 application into appharbor, copying locally System.Web.MVC but still getting this error.
error CS0246: The type or namespace name 'TModel' could not be found (are you missing a using directive or an assembly reference?)
Have you tried to use the NuGet dll - please make sure you're referencing the NuGet dll and not your local system one: https://www.nuget.org/packages/aspnetmvc
Also check out this support issue: http://support.appharbor.com/discussions/problems/1314-error-pushing-mvc4-application

asp.net mvc 4 website is refusing to build on teamcity

I have a Windows Server 2003 box with teamcity that I use as a build/deployment server. I checked in a new asp.net mvc 4 project and it is crapping out with the following errors:
App_Start\BundleConfig.cs(2, 18): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Controllers\AccountController.cs(8, 7): error CS0246: The type or namespace name 'DotNetOpenAuth' could not be found (are you missing a using directive or an assembly reference?)
Global.asax.cs(7, 18): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Models\AccountModels.cs(4, 45): error CS0234: The type or namespace name 'Schema' does not exist in the namespace 'System.ComponentModel.DataAnnotations' (are you missing an assembly reference?)
App_Start\BundleConfig.cs(9, 44): error CS0246: The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?)
I've already installed asp.net mvc 4 on that box, restarted the machine and tried everything else without any luck.
Any ideas?
For me, my CI server (TeamCity) wouldn't take MVC 4 via the Web Platform Installer. Dunno why.
So I checked the TC build logs logs for the yellow warnings, looking for references its trying to resolve.
For each one, I then looked for the corresponding NuGet package in the project/solution and reinstalled it. This sets it up with package restore so that TeamCity/MSBuild restores it during build.
For example:
Update-Package WebGrease -Reinstall
The MVC project template, although it uses NuGet packages, they're not wired-into the whole package restore mechanism for some reason, so reinstalling them forces this. Effectively, I suppose you're installing MVC 4 via its constituent packages.
Luke
A few things I would look in to:
Make sure that your NuGet packages are being pulled down appropriately during the build. Documentation
Make sure that the project is not still referencing the old MVC 3 assemblies somewhere. Perhaps a nant/msbuild build script is copying the old assemblies somewhere?
I am not sure if this will be helpful. But I had same problem. What I was trying to do is using EnableNuGetPackageRestore I was trying to restore it and some where it was causing problem (Restoring nuget packages from Test project rather than MVC project. I am not sure why but if I found out I will surely update thread). What I did is I followed blog from http://blog.jetbrains.com/teamcity/2013/08/nuget-package-restore-with-teamcity/. Adding one more build step NuGet Installer helped me fix issue. (Caution: If you are using internal nuget package server than you need to specify same in Sources). Please let me know if you have still problem and I can be of any help. Happy Building !!

Type or namespace is not found Error when deploying the website

the website works nice on local system but when I deploy it , an exception throws that :
CS0234: The type or namespace name 'ISisoDatabase' does not exist in the namespace 'SisoDb' (are you missing an assembly reference?) ?
it's a shared host by the way .
any idea why this is happening ?
Edit : I used Web Project instead of WebSite and this error is gone but another exception is thrown :
Could not load file or assembly 'SisoDb, Version=15.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The module was expected to contain an assembly manifest.
solved : the problem was the ftp client I used to upload dlls . it sounds ftp corrupted the dlls. when I added assemblies using file manager , the problem was solved
the problem sometimes is the ftp client that is used to deploy files .they corrupt files when uploading them . try uploading files using file manager .

Web service Compilation Error

I have a problem with a web service. I add a web service reference to my project. I use this service in many pages. It is working correctly, no problems in VS but I copy App_WebReferences folder's files and Web.Config file to ISS path. But it is not working.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'InterkomLaboratuar' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 22: InterkomLaboratuar.Service1SoapClient _sistemTip = new InterkomLaboratuar.Service1SoapClient();
Source File: c:\Inetpub\wwwroot\MedulaV3\diyaliz02\Istemler.aspx.cs Line: 22
How can i solve this problem please help..
Copy Bin folder to IIS. You are missing some assemblies.

Resources