简体   繁体   English

将一个Winform添加到另一个项目

[英]Add one winform to another project

I have 3 projects, I want to merge the winforms in each project into one project. 我有3个项目,我想将每个项目中的winforms合并到一个项目中。 How can I do it? 我该怎么做?

First you need to analyse if forms in those 3 projects has any not standard dependencies (references to libraries). 首先,您需要分析这3个项目中的表单是否具有任何非标准依赖性(对库的引用)。 Then you can create new project, add library references from other projects, drag and drop files from old projects to new project, fix namespaces (or preserve them so you dont have collision between similar forms or names from different projects) 然后,您可以创建新项目,添加其他项目中的库引用,将旧项目中的文件拖放到新项目中,修复名称空间(或保留它们,以使不同项目的相似形式或名称之间不会发生冲突)

Straightforward approach would be: 简单的方法是:

  • Create new Project 建立新专案
  • Copy all needed code files in Solution Explorer to the new project 将解决方案资源管理器中所有需要的代码文件复制到新项目中
  • Fix namespaces 修复名称空间
  • Add missing references (if any) 添加缺少的参考(如果有)
  • Drop original projects 删除原始项目
  1. Create a new project 创建一个新项目
  2. In Solution Explorer click Add Existing Items. 在解决方案资源管理器中,单击“添加现有项”。
  3. Add all the forms from different projects (Make sure that name of each form should be different.) 添加来自不同项目的所有表单(确保每个表单的名称都应该不同。)

If you haven't used it before, JetBrain's Resharper could be very useful for you in this case. 如果您以前从未使用过它,在这种情况下,JetBrain的Resharper可能对您非常有用。

To rename the namespace, click on the namespace on the class and hit F2 (hope it works without Resharper). 要重命名名称空间,请在类上单击名称空间,然后按F2(希望它在没有Resharper的情况下可以工作)。

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

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