雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

C# 編譯生成dll文件供程序調(diào)用的兩種方法

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C#教程|點(diǎn)擊:

一、使用vs2017 創(chuàng)建動態(tài)dll文件

方法一:

1、新建-項(xiàng)目-類庫

2、創(chuàng)建一個(gè).cs文件 寫入代碼,例如:建立一個(gè)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("調(diào)用成功!"); 
  } 
 } 
} 

3、運(yùn)行文件,就會在Debug目錄下生成ClassLibrary1.dll文件

方法二:

或者在已經(jīng)寫好的模塊中,選擇項(xiàng)目,右鍵-屬性-輸出類型處選擇類庫

最后 右鍵-重新生成

二、調(diào)用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 調(diào)用DLL 
{ 
 public partial class Fo : Form 
 { 
  public Fo() 
  { 
   InitializeComponent(); 
  } 
  private void button1_Click(object sender, EventArgs e) 
  { 
   Form1 f = new Form1(); //實(shí)例化對象 調(diào)用 
   f.Show(); 
  } 
 } 
} 

總結(jié)

以上所述是小編給大家介紹的C# 編譯生成dll文件供程序調(diào)用的兩種方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對我們網(wǎng)站的支持!

上一篇:C#部署數(shù)據(jù)庫及IIS站點(diǎn)

欄    目:C#教程

下一篇:C# FileStream實(shí)現(xiàn)多線程斷點(diǎn)續(xù)傳

本文標(biāo)題:C# 編譯生成dll文件供程序調(diào)用的兩種方法

本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/5240.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有