C# 反射使用使用外部DLL

 1 private void Init()
 2         {
 3             string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
 4             string dllPath = path + @"\CefWebBorwser\" + "CefWebBrowserControl.dll";
 5             if (System.IO.File.Exists(dllPath))
 6             {
 7                 Assembly assembly = Assembly.LoadFrom(dllPath);
 8                 Type browserType = assembly.GetType("CefWebBrowserControl.CefWebBrowser");
 9                 object browserObj = System.Activator.CreateInstance(browserType);
10                 MethodInfo method = browserType.GetMethod("OpenUrl");
11                 string dataStatisticUrl = $"http://{UserHelper.Instance.CurrentUser.ServerIp}:{UserHelper.Instance.CurrentUser.WebPort}/#/login.html?userSession={_websocketService.GetSession()}&lang={GetLang()}&route=2";
12                 CommonHelper.LogDebug("dataStatisticUrl:" + dataStatisticUrl);
13                 method.Invoke(browserObj, new object[] { dataStatisticUrl });
14                 System.Windows.Forms.UserControl browser = (System.Windows.Forms.UserControl)browserObj;
15                 browser.Dock = DockStyle.Fill;
16                 host.Child = browser;
17             }
18         }

 

C# 反射使用使用外部DLL

上一篇:(转载)Net 下采用GET/POST/SOAP方式动态调用WebService C#实现


下一篇:洛谷 P1854 花店橱窗布置/ACWing 313 花店橱窗 题解