最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C# 编译生成dll文件供程序调用的两种方法
时间:2022-06-25 07:44:30 编辑:袖梨 来源:一聚教程网
一、使用vs2017 创建动态dll文件
方法一:
1、新建-项目-类库
2、创建一个.cs文件 写入代码,例如:建立一个Windows窗体
略丑,简单明了。。。
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;
namespace ClassLibrary1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("调用成功!");
}
}
}
3、运行文件,就会在Debug目录下生成ClassLibrary1.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 System.Runtime.InteropServices;
using ClassLibrary1; //引入命名空间
namespace 调用DLL
{
public partial class Fo : Form
{
public Fo()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f = new Form1(); //实例化对象 调用
f.Show();
}
}
}
相关文章
- 12306火车票余票查询官网入口-火车票实时查询入口 02-12
- 淘宝特价版vs淘宝区别-淘宝特价版商品保真吗 02-12
- duyin抖音网页版官方入口-duyin抖音官网首页地址 02-12
- tiktok国际版极速下载安装入口-tiktok国际版安卓最新版本 02-12
- duyin抖音官网首页网页版入口-duyin抖音官网首页直达地址 02-12
- 夸克官网入口-智能搜索浏览器2026最新地址 02-12


