日期:2014-05-17 浏览次数:21073 次
下面是自己写一个简单的例子:
先定义一个接口,将其生成dll文件,命名为server.dll
using System.Text;
namespace PluginInterface
{
public interface IShow
{
void Show();
}
}
然后写主程序,引用server.dll,将主程序生成.exe的可执行文件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using PluginInterface;
namespace MainFormProj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
try
{
string path = Application.StartupPath;
path = System.IO.Path.Combine(path, "Plugins");
foreach (string file in System.IO.Directory.GetFiles(path, "*.dll"))
{
listBox1.Items.Add(file.Substring(file.LastIndexOf("\\") + 1));
}
listBox1.Click += newEventHandler(listBox1_Click);
}
&nbs