简体   繁体   English

如何添加对WinForm项目的引用?

[英]How to add a reference to a WinForm project?

I have a few winform projects in different solutions. 我在不同的解决方案中有一些winform项目。

If I have two winform projects in the same solution, when I add a reference, I go on the Projects tab and from there I can reference my other projects. 如果我在同一个解决方案中有两个winform项目,当我添加一个引用时,我会进入Projects选项卡,然后从那里我可以引用我的其他项目。 But how can I reference a winform project when it is in a different solution? 但是,当它处于不同的解决方案时,如何引用winform项目? There seems to be no file I can use when I browse the windows explorer. 我浏览Windows资源管理器时似乎没有可以使用的文件。

Thank you! 谢谢!

Use the Browse tab in the Add Reference dialog and select the assembly you would like to add as reference from the file system: 使用“ Add Reference对话框中的“ Browse选项卡,从文件系统中选择要作为引用添加的程序集:

在此输入图像描述

It would be a good idea to have a lib folder inside your second solution in which you would put all third party assemblies that are required by it so that it is totally independent. 在第二个解决方案中包含一个lib文件夹是一个好主意,在该解决方案中,您将放置它所需的所有第三方程序集,使其完全独立。 So inside this lib folder you would put the generated assembly from some other project in some other solution. 因此,在这个lib文件夹中,您可以将生成的程序集放在其他一些解决方案中。 Note that an assembly doesn't necessarily means DLL. 请注意,程序集不一定表示DLL。 It could be an EXE as well. 它也可能是一个EXE。

You can add the project itself to your solution, then add a project reference to it. 您可以将项目本身添加到解决方案中,然后向其添加项目引用。 Or you can add a reference to the binary of that project. 或者您可以添加对该项目的二进制文件的引用。

You can add the project to your solution (one project can be in more than one solution). 您可以将项目添加到解决方案中(一个项目可以在多个解决方案中)。

Another option would be to add the compiled assembly (.exe or .dll) as a normal reference. 另一种选择是将编译的程序集(.exe或.dll)添加为普通引用。

You need to add the project to the solution in order to add a reference. 您需要将项目添加到解决方案以添加引用。 You can do that by right clicking the solution --> Add existing project. 您可以通过右键单击解决方案 - >添加现有项目来实现。

You can easily have the same project in different solutions without problems. 您可以轻松地在不同的解决方案中使用相同的项目。

You can also add a reference to the generated assembly, but you may lose some debugging capabilities. 您还可以添加对生成的程序集的引用,但可能会丢失一些调试功能。

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

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