简体   繁体   中英

Namespace / Class Qualifier

I have a solution with several projects. One of them is Contexts (where the default namespace is XYZ), and another is BackOffice (where the default namespace is XYZ.BackOffice). BackOffice has a reference to Contexts.

I created a new class (Foo) in Contexts and I specified that Foo's namespace is XYZ. I then wrote some code in BackOffice that used Foo. I DID NOT QUALIFY Foo when I used it, nor did I add a using directive, and the build failed, as I expected. I then changed all Foo to XYZ.Foo and did another build. This time it was successful. I then removed the XYZ's that I had just added, and the build is STILL successful.

How is it now "remembering" the namespace? I did a clean and rebuild; no change. I dropped Foo from Contexts and re-add it; VS2008's automatic error checking showed the errors I expected, but then the next build was still successful.

This only bothers me because I fear that, although I get a successful build, when my teammates check out my code, they may not.

You must have a namespace qualifier somewhere. It may have a using somewhere that didn't get removed. Close your project and reopen. Sometimes there is a cached version of VS projects that probably is not getting updated in your case. Not sure what else to look for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM