Visual Studio 2010中:如何引用一个C#.NET类库项目,第三部分依赖类库、部分、项目、Studio

2023-09-06 05:29:14 作者:柠檬小丸子

这可能是一个很基本的问题,但我还没有找到如何的项目引用工作在Visual Studio中的任何详细信息。

This is probably a very basic question but I haven't found any detailed information about how project references works in Visual Studio.

我有一个包含MainApp项目和一个C#类库项目里面的第三方组件的一个Visual Studio 2010的C#的解决方案。当提到从MainApp项目的类库项目,我应该只是添加项目引用或做我需要添加对第三方组件类库项目中呢?

I have a Visual Studio 2010 C# solution containing a MainApp project and a C# class library project with third party assemblies inside. When referring to the class library project from the MainApp project, should I just add a project reference or do I need to add references to the third party assemblies within the class library project as well?

在某些情况下,这似乎是不正确加载,如果我只是在我的MainApp项目中的类库项目引用,尽管所有的DLL文件(包括第三方的DLL)显示在输出文件夹创建完整的时候,第三方组件解决方案。

In some cases it seems like the third party assemblies are not loaded correctly if I just have the Class Library project reference in my MainApp project although all DLL files (incl third party DLLs) show up in the output folder when building the complete solution.

编辑:我已经发布了一个更具体的问题,因为一般的答案在我的情况没有帮助:How指自包含的C#类库项目的IronPython内(Visual Studio 2010中)

I've posted a more specific question since the general answer did not help in my case: How to refer self-contained C# class library project with IronPython inside (Visual Studio 2010)

推荐答案

在使用THRID方组件/ DLL的,我觉得它BECT在一个叫做相关性项目中创建一个文件夹,然后将它们放在那里,这样,他们不要吨得到丢失或隐藏在其中包括源代码。

When using thrid party assemblies/dlls I find it bect to create a folder in a project called "Dependencies" and place them in there, that way they don't get lost or hidden in amongst your source.

您的类库项目应参照THRID党集会。你需要浏览那些,然后设置复制本地属性,即(点击添加引用后)这样,他们将被复制到其中任何编译code放置的目录。

Your class library project should reference the thrid party assemblies. You'll need to browse for those (after clicking add reference) and then set the Copy Local property True, that way they will be copied to the directory into which any compiled code is placed.

您其他的项目只需要点击添加引用后,从项目列表中引用您的类库项目(记得要设置复制本地属性),选中它

Your other project just needs to reference your class library project(remember to set the Copy Local property), select it from the Projects list after clicking add reference.

哦,我忘了补充您的$引用任何公众对引用的程序将需要使用语句C $ C文件链接到他们。

Oh I forgot to add your code files that refer to any publics on the referenced assemblies will require a using statement to link to them.