ASP.NET MVC program fails to compile after most recent patch Tuesday - c#

I am using MVC 5, C#, .NET 4.5.1 in Visual Studio 2013. Following a Microsoft/Windows Update yesterday (15 October 2014) my program refuses to compile with multiple errors of the two types below:
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'
The type or namespace name 'ControllerContext' could not be found (are you missing a using directive or an assembly reference?)
I have tried this on a different computer (also with the patches) and had the same errors. The program in question is in production and compiled perfectly before the changes.
Before I start uninstalling and restoring the different patches, has anyone else seen this problem and is a solution/workaround known.

I got the same error yesterday. I assumed it was something I had done. One of the projects in our solution had a reference to System.Web.Mvc 4.0.0.0 and it could no longer find it. I updated that project using NuGet to System.Web.Mvc 5.2.0.0 (which is what all the other projects in the solution were using anyway) and all was well.

Related

Type or namespace name does not exist when build on Travis CI

I have a .Net project using NUnit Testing built with Visual Studio 2019, which is working fine on local. But when I push the project to origin/master Github with Travis CI, it was giving me messages like:
The type or namespace name 'Point' does not exist in the namespace 'Triangle' (are you missing an assembly reference)? [/home/travis/build/phamhoangvu922/TriangleTesting/Triangle.Test/Triangle.Test.csproj]
I've worked through all of the issues such as making sure all the projects in the workspace are using the same version of .Net for the Target Framework setting etc but not works for me.
How can I fix it?

IntelliSense complains about missing Microsoft.AspNetCore packages despite being there

In my Blazor application, on the client side, IntelliSense complains about a lot of Microsoft.AspNetCore packages although the project compiles and runs fine.
I get a lot of things like
The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
...
Things like
#inject HttpClient Http
are also underlined with red squigglies.
The project builds and runs perfectly.
What is wrong here?
Followup 1
Because I was asked for all versions:
Visual Studio 2019, 16.0.2
Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview4-19216-03
In my project:
Id Versions ProjectName
-- -------- -----------
Microsoft.AspNetCore.Blazor.Build {3.0.0-preview4-19216-03} MyBlazorApp.Client
Microsoft.AspNetCore.Blazor {3.0.0-preview4-19216-03} MyBlazorApp.Client
NETStandard.Library {2.0.3} MyBlazorApp.Client
You need Visual Studio Preview version 16.1 or higher to work with 3.0.0-preview4 Blazor.
If that alone doesn't help, verify that you dont have any .cshtml files in your client project - they all have a .razor extension since 3.0.0-preview4. The presence of .cshtml file triggers a different SDK's behavior, requiring AspNetCore.Mvc namespace. Though Microsoft guys see it as a bug and probably will fix it.
https://github.com/aspnet/AspNetCore/issues/9640
Shut down VS
Delete the .vs folder or the .suo file
Restart VS
uninstalling x86 version of .NET Core 3.0 Preview SDK
https://dotnet.microsoft.com/download/dotnet-core/3.0
Then installing the x64 again on Windows10 64bit fixed that issue for me

Getting namespace does not exist error for all the references added in my project

Whenever I take the latest code from TFS and tries to build existing solution, It fails all the project building and says that : The type or namespace name 'XYZ' does not exist in the sampace 'a.b.c' (are you missing an assembly reference?)
This is happening with all the references and only in my system. On the other systems all these code works fine.
Can it be a Visual Studio issue or some setting which might have got changed?

Microsoft.Bcl package using CallerMemberName fails to build within Teamcity

I have taken over a project that is targeting .net4.
One of the projects within the solution is using System.Runtime.CompilerServices.CallerMemberNameAttribute from the System.Runtime.dll that is installed when you are using the Microsoft BCL Portability Pack.
I have checked and the project is currently using version 1.1.3.
When the solution is build on local dev machines, everything compliles with no problems.
I am now trying to get the solution built in teamcity, but when TeamCity attempts to compile the solution I am getting this error.
error CS0246: The type or namespace name 'CallerMemberName' could not be found (are you missing a using directive or an assembly reference?)
error CS0433: The type 'System.Runtime.CompilerServices.CallerMemberNameAttribute' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll' and 'c:\apps\teamcity\buildAgent\work\bb8aacaa9fabeac8\packages\Microsoft.Bcl.1.1.3\lib\net40\System.Runtime.dll'
I have read Jon Skeets answer to this question: Using CallerMemberName attribute in a portable library But I am already using the BCL library.
After spending some time on this, I found another question answered by Jon Skeet that resolved this issue.
When must we use extern alias keyword in C#?
Within my project, after getting the links to the Package, for each dll I had to change the name of the alias. ie from global to newglobal
Then in the classes that where using the CallerMemberName, had to do the following
At the top of the page, above the using statements
extern alias newglobal;
And then when referencing CallerMemberName, enter the code as
[newglobal::System.Runtime.CompilerServices.CallerMemberName]
This allows the code to be successfully built on teamcity where .net 4.5 has been installed.

c# namespace name cannot be found

I am trying to make an asynchronous client for Windows Phone using this code http://msdn.microsoft.com/en-us/library/bew39x2a.aspx in Visual Studio 2010 but I get 22 errors for using things like IPHostEntry and BeginConnect although I copied the code exactly. Any ideas?
Thanks
Edit
The three different types of errors I'm getting are below. most of them are the third one with sockets.socket
Error 1 The type or namespace name 'IPHostEntry' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The name 'Dns' does not exist in the current context
Error 3 System.Net.Sockets.Socket' does not contain a definition for 'BeginConnect' and no extension method 'BeginConnect' accepting a first argument of type 'System.Net.Sockets.Socket' could be found (are you missing a using directive or an assembly reference?)
You may be missing a reference. Verify that the appropriate DLLs have been identified as project references.
You should check to see if your project is using the correct version of .Net. In .net 4.0 there is both a "client" and "full" version. Typically when you create a new .Net project in Visual Studio the project is created and referencing the "client profile" .net. Honestly, this gets me every time.
You can change this by doing the following (Visual Studio 2010):
Right click the project in Visual Studio Solution Explorer and select "Properties"
Make sure the "Application" tab is selected
View / Change the "Target Framework:" from ".NET Framework _ Client Profile" to ".NET Framework _"
rebuild your project :-)
Here's a good link explaining the difference between the client profile and the full profile: Differences between Microsoft .NET 4.0 full Framework and Client Profile
The code is missing a namespace before it is declaring classes.
namespace YourNamespace
{
// State object for receiving data from remote device.
public class StateObject { ...
Also you may be missing namespaces for stuff the code is using. Click on the classes that are highlighted with red squigglies and press ctrl + . and it should give suggestions for namespaces.
I encountered the same issue today. I think it's because VS2010 Express WP created my project using 2.0 .NET framework, I don't know why, I want to use 7.8, but I have only choice between 7.0 and 7.1. I can't change .Net framework version for use the 4.0/4.5, I have only one choice and it's windows phone 7.1, I can't choose the version of the framework separately...

Categories