C# 窗体封装为dll文件供另一个项目窗体调用
一、使用vs2015 创建动态dll文件
方法一:
1、新建-项目-类库;
2、创建一个.cs文件 写入代码,例如:建立一个Windows窗体;

3、运行文件,就会在Debug目录下生成Test.dll文件,具体设置方法:选择项目,右键-属性-输出类型处选择类库

二、调用ClassLibrary1.dll文件方法
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using WPForm;using Test;using System.Runtime.InteropServices;using System.Threading.Tasks;namespace VisionTest{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){//WPForm form1 = new WPForm();test1 form1 = new test1();//CreateMDIControl(new test1());form1.Show();}}}
最终效果:

赞 (0)
