[Solution] After adding a reference to. net, but cannot find the namespace when using in the code?

Source: Internet
Author: User
Tags visual studio 2010

A c/s project framework has been built over the past few days, and a problem that has not been noticed before is found:

After Project A (. csproj) under the same solution (. sln) references the. dll of Project B, you cannot find the corresponding namespace by using in the code.

As shown in figure 1, MCC. client references the. dll generated by the MCC. Business project, but in Figure 2,Error 2 the type or namespace name 'userprofile 'cocould not be found (Are you missing a using directive or an assembly reference ?) C: \ Documents ents and Settings \ a531032 \ My Documents ents \ Visual Studio 2010 \ projects \ MCC. Client \ sysutility \ appcontext. CS 15 24 MCC. Client.

Figure 1 Solution Structure

Figure 2 Compilation Error

Because I have modified the project name before and thought it was the cause of the reference failure, I checked the error in the following direction and finally found the cause.

  • Check whether the assemblytitle and assemblyproduct files in the properties/assembly. CS file of the referenced Project (MCC. Business Project in this example) are correct? 3.

Figure 3 properties/assembly. CS file of MCC. Business

  • Right-click to check whether the properties of the referenced Project (MCC. Business Project in this example) are correct? 4.

Figure 4 properties page of MCC. Business

  • Check whether the value in. csproj of the referenced project is consistent with the assembly information of MCC. Business? 5.

Figure 5. csproj file of MCC. Client

  • Check the property page of the referenced project. Is the field "target framework" set to ". NET Framework 4 client profile "? 6.

Figure 6 properties page of MCC. Client

Problem Found

My problem is that when creating the MCC. Client project (a winform project), vs 2010 selects ". NET Framework 4 client profile" by default to facilitate client deployment. However, because the MCC. dataaccess project references system. Data. oracleclient (it is not included in the. NET Framework 4 client profile library, but in the. NET Framework 4 full library ). Then, MCC. business references MCC. the. DLL, when MCC. client references MCC. generated by business. DLL. DLL references again. NET framework 4 client profile does not contain content, so MCC. client to MCC. business. DLL provides a compilation error.

======================================

Differences between. NET Framework 4 client profile and. NET framework 4

  • Is a subset of the latter.
  • Reduces the deployment time of. NET Framework and. NET Framework applications.
  • Failed to deploy. NET Framework.
  • Reduce the size of the. NET Framework in the isV software, so as to provide more space for the software.
  • Reduce the "interface" of the system where the. NET Framework client profile is installed because the client profille contains ASP. NET and the components required by some servers.
  • We can see the difference in size between the two.

Refer to blog posts from networks:

  • Analysis and discussion of "unprecedented bug" on csdn
  • Stackoverflow on foreigners
  • . NET Framework 4 client profile, which is shared with. NET Framework 4 full. dll

For personal study, please refer to it for your reference only ~

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.