简体   繁体   English

在 c# 中添加现有项目

[英]Adding existing project in c#

I have add the existing project in my new project, but when I try to use the existing library, I see the following error:我已经在我的新项目中添加了现有项目,但是当我尝试使用现有库时,我看到以下错误:

the type or namespace name 'com' could not be found (are you missing a using directive or an assembly reference?)找不到类型或命名空间名称“com”(您是否缺少 using 指令或程序集引用?)

What would cause this?什么会导致这个?

you must add in your main project reference to other project您必须在主项目中添加对其他项目的引用

(project's property -> add reference -> projects -> select your second project ) (项目的属性 -> 添加参考 -> 项目 -> select 您的第二个项目)

or you must add或者你必须添加

    using com;

If you have already added the reference to the project then try adding a using for the added class in the.cs file where you want to use it:如果您已经添加了对项目的引用,请尝试在要使用它的 .cs 文件中为添加的 class 添加using

using com;

Right click the name of the project you want to add the library to > Select Add Reference , in the dialog box, > select Projects.右键单击要将库添加的项目名称 > Select Add Reference ,在对话框中 > select Projects。 > Select and ADD the library. > Select 并添加库。

Reference the library in the 'using' section of any class you wish to access the library.在您希望访问该库的任何 class 的“使用”部分中引用该库。

using System;
using <nameofproject>

Also read this article.另请阅读这篇文章。

http://www.csharphelp.com/2006/02/namespaces-in-c/ http://www.csharphelp.com/2006/02/namespaces-in-c/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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