"Failed to find the type name or namespace name xxx ..." error while resolving Visual Studio writing C #

Source: Internet
Author: User

You have a wonderful problem, when Visual Studio writes C # with a hint:

"Could not find the type name or namespace name XXX (whether a using directive or assembly reference is missing)"

Check it out,
1, neither I do not have this class,
2, nor did I write "Using XXX;" To reference namespaces,
3, more than I referenced the other. dll files, forget to add references,
4. There is no spelling error in the end.

It's really a pit. Checked for a long time.

The reason for the final discovery is:

This class is not included in the compilation, and the namespace does not take effect.

Workaround:
Open the "Welcome.csproj.user" file under Project Engineering, "Welcome" is the project name.
Locate the label, and add the file for the class that does not find the type name or namespace.

such as PG PG = new PG ();

Tips:
"Could not find the type name or namespace name XXX (whether a using directive or assembly reference is missing)"

Find the corresponding file "Program1.cs" for the PG class, add:

 <ItemGroup> 
    <compile include= "MainTest.cs"/> <compile
    Include= "Program1.cs"/> <compile include= "Program2.cs"/> <compile include=
    "Program3.cs"/>
    <compile include= "ArrayTest.cs"/>
    <compile include= "Properties\assemblyinfo.cs"/>
  </ Itemgroup>

Then save, refresh, clean, and rebuild, and it's OK (maybe refreshed).
I'm surprised that vs why didn't automatically join. Maybe there's something wrong with my project.

In fact, when you create a new file, the new resource will be compiled directly into the current project from the item on the menu bar, add xx, and the item from "File"-"new"-will not be added directly to the current project, and can also cause an appeal issue.

So:
In fact, this is what the code layer renders. In fact, it can also be resolved in the Visual Studio view layer. In fact, click "Project"-"Show All Files", and then in Solution Manager you can find a C # file that is not joined to the compile queue, right-click it, and select "Include In Project (j)". The refresh is OK.

end--

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.