'Visual studio does not recognize newly added class
I am having a weird issue here, i am using vs 2019 and one of my projects refuses to recognize any newly added c# classes, i can not use it anywhere else in the project. This is just an empty class. The new class has no little triangle to the left of it too.
I have tried clean and rebuild this project and did not help, my other projects in the same solution do not have this problem, i am thinking probably i messed up with something in this mvc project but not sure.
this is very frustrating, any help is very much appreciated.
I have fixed this by updating Microsoft.Net.Compilers from 1.0.0 to 3.5.0, and then as its description suggested, use Microsoft.Net.Compilers.Toolset.3.5.0 instead.
I am not sure i completely understand, but seems the problem is that this project uses Microsoft.Net.Compilers instead of MSBuild and the package is out dated.
Solution 1:[1]
I have fixed this by updating Microsoft.Net.Compilers from 1.0.0 to 3.5.0, and then as its description suggested, use Microsoft.Net.Compilers.Toolset.3.5.0 instead.
I am not sure i completely understand, but seems the problem is that this project uses Microsoft.Net.Compilers instead of MSBuild and the package is out dated.
Solution 2:[2]
This solve the issue: update the package Microsoft.Net.Compiler to the latest version, compile and try adding a new class to your project again.
Solution 3:[3]
In your screen clip, note the lack of the triangle to expand the member list. This likely means your code isn't being compiled. Right click on the cs file and check properties/build action. Set to "compile" if it's not already.
Solution 4:[4]
publish the project and classes are recognized
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kevin Ma |
Solution 2 | Gxzzin |
Solution 3 | user3091705 |
Solution 4 | Primoz Bratina |