加载动态库

//加载动态库
private void LoadDll()
{
//获取系统环境路径
string sysPath = System.Windows.Forms.Application.StartupPath;
string xmlFile = "";
xmlFile = sysPath + "/StationInfo.xml";
//实例化Xml文档类
XmlDocument xmlDoc = new XmlDocument();
//加载Xml文件
xmlDoc.Load(xmlFile);

XmlNode devicesNode = xmlDoc.SelectSingleNode("StationInfo/dllList");
XmlNodeList xnl = devicesNode.ChildNodes;
//遍历dllList节点,加载所有的Dll
foreach (XmlNode xn in xnl)
{
XmlNode name = xn.SelectSingleNode("name");
XmlNode path = xn.SelectSingleNode("path");
string DllPath = sysPath + path.InnerText;
DllList.Add(name.InnerText, Assembly.LoadFrom(DllPath));
}

XmlNode datNode = xmlDoc.SelectSingleNode("StationInfo/Dat");
XmlNode datName = datNode.SelectSingleNode("name");
XmlNode datPath = datNode.SelectSingleNode("path");
DatList.Add(datName.InnerText, datPath.InnerText);

}

原文地址:https://www.cnblogs.com/qiulang/p/3325814.html