Visual Studio 2010:如何引用具有第三方依赖关系的C#.Net类库项目 [英] Visual Studio 2010: How refer to a C# .Net class library project with third part dependencies

查看:1816
本文介绍了Visual Studio 2010:如何引用具有第三方依赖关系的C#.Net类库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我有一个Visual Studio 2010 C#包含MainApp项目和C#类库项目的解决方案,其中包含第三方组件。在引用MainApp项目中的类库项目时,应该只添加项目引用,还是需要在类库项目中添加对第三方程序集的引用?


$ b $在某些情况下,如果我在MainApp项目中只有类库项目引用,似乎第三方程序集未正确加载,尽管构建所有DLL文件(包括第三方DLL)都会显示在输出文件夹中完整的解决方案。



编辑:我发布了一个更具体的问题,因为一般答案在我的情况下没有帮助:如何引用自包含的C#类库项目使用IronPython(Visual Studio 2010)

解决方案

使用第三方程序集/ DLL时,我发现创建项目中的文件夹c所有的依赖关系,并将它们放在那里,这样他们就不会丢失或隐藏在你的来源之间。



你的类库项目应该引用第三方聚会。您需要浏览这些(点击添加引用)后,然后设置复制本地属性 True 方式他们将被复制到任何已编译代码所在的目录。



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



哦忘记添加引用程序集中任何公开的代码文件,需要使用语句链接到语句。


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

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?

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.

Edit: 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)

解决方案

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.

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.

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.

这篇关于Visual Studio 2010:如何引用具有第三方依赖关系的C#.Net类库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆