When compiling a. Net project, the system namespace cannot be found. Add system component references. This component has been correctly referenced by this project)

Source: Internet
Author: User
A few days ago, a colleague remotely logged on to my machine and made some modifications to one of my projects. Yesterday, I opened and changed the project compilation, and there were a lot of errors about "cannot find the system namespace, please add component references". I saw that these system components have been correctly referenced, I had to delete all of them and add references. Now, the compilation is successful.
Today, I opened the project for compilation and prompted the same error. Those system components were still correctly referenced. So I solved the problem by yesterday's method. Close vs20003 and compile again. The same error occurs again. System components are still referenced. However, I found that all those components are copied to the bin directory of the Project. When you look at the component attributes, copying them to the local directory is "true". Therefore, I deleted all of them, added them all, and changed the "Copy to local" attribute to "false". The compilation was successful, the system components were inexplicably copied to the bin directory, and all the "false" that I manually set became "true. Generally, the "Copy to local" attribute of the system component is "false", only for c: \ windows \ Microsoft. net \ framework \ v1.1.4322 component reference, will not copy the file to the bin directory, but my project is the opposite, and, after manual modification, it was automatically changed back by vs2003. We were disappointed that we were about to re-build the project and add all the files to the project. However, we felt too much trouble. Let's see if there were any more time-saving and labor-saving solutions.
So I started to view the project properties, and the reference path settings shown in attracted my attention.

(Note: C: \ WINDOWS \ Microsoft. net \ framework \ v1.1.4322. common \ bin \ Debug) without referencing the system component path, so I tried to set C: \ WINDOWS \ Microsoft. net \ framework \ v1.1.4322 \ is added, compiled, or not passed. As a result, I deleted all the system components and added them to the compilation process. But after vs2003 was disabled, the same error occurred. The system components were still copied to the bin directory. At this time, I think it is related to the order of the referenced paths above. Otherwise, how can I set the order button above? Then I set C: \ WINDOWS \ Microsoft. net \ framework \ v1.1.4322 \ to the first issue, then delete the system component, add and compile it, and then close vs2003. The compilation is still successful, and finally solved this depressing problem.
Summary: apart from the "Copy to local" attribute of each component, the "Reference Path" setting of the project also takes effect in the reference mode of the component. When a component is referenced, the path in the "Reference Path" setting is searched. If the path does not exist, for example, the system component path, vs2003 automatically copies the modified component to the bin directory of the project, regardless of the "Copy to local" attribute of the added component. However, I found that the newly created project does not contain c: \ windows \ Microsoft. net \ framework \ v1.1.4322 \ references only to its bin directory. I think it may be the automatic mechanism of vs2003. When creating a project, the path of the system component is already default, although it cannot be seen in the "Reference Path", but it puts the reference to it first, this can also be seen from the other hand, we noticed that during the creation of a project, vs2003 automatically added a reference to common system components, and these components do not have copies in the bin directory, that is, they only reference the system component path. Maybe my colleague has changed the default path rule of vs2003 so that it does not include c: \ windows \ Microsoft in the "Reference Path" setting. net \ framework \ v1.1.4322 \ is the preferred path, but the bin directory of the project is the preferred path, which is why I cannot find the component during compilation. Up to now, I have no idea where the default path reference rule of vs2003 has been changed. Maybe it has not changed at all, but the negligence of vs2003 developers. Since C: \ windows \ Microsoft. net \ framework \ v1.1.4322 \ is the preferred path. Why is it missing in the "Reference Path" setting of the project? After some operations, the default rule is revoked, but the component is loaded according to the reference path setting.
If you have a deep understanding, please give me some advice.

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.