Intro
Using visual studio to compile a. Net MVC project, many errors are reported in the following form:
CS0246 The type or namespace name 'xxx' could not be found (are you missing a using directive or an assembly reference?)
CS0246 Typ- oder Namespace-Name "xxx" nicht gefunden (fehlender Verwendungshinweis oder Assembly-Referenz?)
Screenshot:
Similar to in Java, if you directly use some class definitions
without importing related packages, a similar error will be reported.
CS 0246
official document of error code: compiler error cs0246 | Microsoft docs
solve
In the above screenshot, the solution has been given:
is actually to add the correct class path using XXX
.
However, in different versions of visual studio, does not introduce the same shortcut keys in the namespace
where the class is located.
There are three ways to try:
Alt+Enter
Ctrl+.
Shift+Alt+F10
Of course, if you don’t know the shortcut key, but you know the full path (namespace, classname) of the class you are using, you should add using XXX at the beginning of the source code
is OK.
Read More:
- Visual Studio Code Error command ‘markdown.extension.onBackspaceKey’ not found
- [Solved] The type or namespace name ‘Service’ does not exist Error
- Visual Studio 2012 error C4996: ‘scanf’: This function or variable may be unsafe.
- Solution for Visual Studio 2012 compilation error [error C4996:’scanf’: This function or variable may be unsafe.]
- [Solved] Unity Error: Visual Studio Editor Package version 2.0.11 is available……..
- [Solved] Spring cloud introduces zuul dependency error
- [Solved] CMake Error: Could not create named generator Visual Studio 16 2019
- [Solved] Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), v
- Visual Studio SignTool Error: No certificates were found that met all the given criteria.
- [Solved] CMake Error: Could not create named generator Visual Studio 16 2019 -A Win64
- [Solved] CUDA fails to compile in visual studio and throws error msb3721 and nvcc fatal
- SpringBoot IntegratenRedis Annotations and access error: EL1008E: Property or field ‘getListMember‘ cannot be found on object of type
- [Solved] Error: Main class not found or could not be loaded com.jawasoft.
- QT Error: ‘C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe‘ failed
- maven Error: Element ‘dependency’ cannot have character [children], because the type’s content type is
- How to Solve Error: Element ‘dependency’ cannot have character [children], because the type’s content type is element-
- Error (active) e1696 cannot open source file “errno.H” rpgworld problems encountered in installing visual studio 2017
- [Solved] “Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“
- [Solved] TypeError: super(type, obj): obj must be an instance or subtype of type
- [Solved] Android Studio Error:SDK location not found.