System':A Namespace with This Name Does Not Exist

System' : a namespace with this name does not exist

Set Common Language RunTime Support to be "Common Language RunTime Support (/clr)" in 2 places in your project properties :

For Visual Studio before 2019:

  • Configuration Properties -> General
  • Configuration Properties -> C/C++ -> General

For Visual Studio 2019:

  • Configuration Properties -> Advanced -> C++/CLI Properties
  • Configuration Properties -> C/C++ -> General

using namespace System; in Visual Studio 2013

To formalize and expand on my comment, the Console class and generally the System namespace are part of the .NET framework.

In that context, the "C++" tab included in the MSDN documentation page of the Console::SetCursorPosition(int, int) method actually refers to the C++/CLI language. The C++/CLI language is distinct (although intentionally similar) from the C++ language. Correspondingly, the C++/CLI language contains various constructs which are not recognized by the C++ compiler toolset used when compiling Win32 projects.

In other words, to get rid of the "Error: name must be a namespace name" error, you would need to convert your Win32 C++ project to a CLR project. The easiest way to do that would be to create a new project, selecting one of the templates under "Visual C++" / "CLR":

Creating new C++ CLR project

The equivalent of .lib file depdendencies (relative to your Lib Files as Linker Input link) of Win32 projects for CLR project would be assembly references. You'd then typically add those assembly references with "Add References" under "Common Properties , References" project properties:

CLR assembly references

However, in your specific case you may very well find out that the System assembly reference is already included as part of the CLR project template.
You may want to check How to: Add or Remove References on MSDN for more details.

Finally, if you absolutely want to manually convert an existing Win32 project, you would need to set the "Common Language Runtime Support" project properties under "General" and the "C/C++ , General" tabs to one of /clr, /clr:pure, /clr:safe or /clr:oldSyntax (depending on your specific application requirements; if you're just toying around you might want to start with /clr) for all Configurations and Platforms as well as specify the targeted .Net framework version by directly editing the .vcxproj (as indicated in this answer). You would also still need to add assembly dependencies as with the new project approach above.

The type or namespace name 'System' does not exist in the namespace 'Windows.Win32'

Turns out it was an sdk bug. I upgraded to .net sdk 6, and the problem went away.

Found the solution based on these:

https://github.com/microsoft/CsWin32/issues/7

https://github.com/dotnet/wpf/issues/3404

the name ... does not exist in the namespace clr-namespace ...

Every time it happend to me i just restarted visual studio, re-built the solution and it worked just fine.. can't say why

The type or namespace name does not exist in the namespace (are you missing an assembly reference?)

Your GlobalClass is in the namespace ProiectSera.App_Code.

So the class name is ProiectSera.App_Code.GlobalClass

Make sure you don't have a ProiectSera class in the ProiectSera namespace also, otherwise if declaring using ProiectSera on top, it'll try to use it (as a general rule, don't name any class the same as your namespace).

If that still doesn't work, you may want to try using the global namespace:

global::ProiectSera.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);

and see if that works: if it doesn't, and GlobalClass is in the same project, then there's something else you haven't shown us

Update

The only other thing that comes to mind, if you are positive that both files are on the same project/assembly, is that GlobalClass.cs is not being actually compiled. Make sure the Build Action is set to Compile (you can see the build action right clicking on the GlobalClass.cs in the solution explorer and selecting Properties).

The type or namespace name 'Device' does not exist in the namespace 'System'

The type or namespace name 'XXX' could not be found...

Always bear in mind, if you get this error there are three possibilities.

  1. You missed the using directive.
  2. You missed the Assembly reference
  3. You have "using directive" as well as "Assembly reference" in place but the current project's target framework version is lower than the referenced assembly target framework version.

Almost all the cases above three steps should solve the problem.

Hope this helps.

The name does not exist in the namespace error in XAML

When you are writing your wpf code and VS tell that "The name ABCDE does not exist in the namespace clr-namespace:ABC". But you can totally build your project successfully, there is only a small inconvenience because you can not see the UI designing (or just want to clean the code).

Try to do these:

  • In VS, right click on your Solution -> Properties -> Configuration Properties

  • A new dialog is opened, try to change the project configurations from Debug to Release or vice versa.

After that, re-build your solution. It can solve your problem.



Related Topics



Leave a reply



Submit