public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string pathToDll = AppDomain.CurrentDomain.BaseDirectory + @"App.Core.dll"; //Full path to dll you want to load
string typeName = "App.Core.Sockets.ServerSocket";
string subDir = AppDomain.CurrentDomain.BaseDirectory;
AppDomainSetup setup = new AppDomainSetup();
setup.PrivateBinPath = subDir;
setup.ApplicationBase = subDir;
AppDomain newDomain = AppDomain.CreateDomain(subDir, null, setup);
byte[] file = File.ReadAllBytes(pathToDll);//dll path is a dll inside subDir
Assembly assembly = newDomain.Load(file);
var obj = assembly.CreateInstance(typeName);
obj.ToString();
}
}
No comments:
Post a Comment