Program.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Reflection;
  3. using System.Windows.Forms;
  4. namespace OTSIncAReportApp
  5. {
  6. static class Program
  7. {
  8. /// <summary>
  9. /// 应用程序的主入口点。
  10. /// </summary>
  11. ///
  12. static Program()
  13. {
  14. string privatepath = "System;Common;DevExpress;FEIAutoScript;SQLiteDll;OxfordExtender;OTSCPPDll;OpenCvSharp;CefSharp";
  15. AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", privatepath);
  16. AppDomain.CurrentDomain.SetData("BINPATH_PROBE_ONLY", privatepath);
  17. var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
  18. var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
  19. m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privatepath });
  20. }
  21. [STAThread]
  22. static void Main(string[] args)
  23. {
  24. Application.EnableVisualStyles();
  25. Application.SetCompatibleTextRenderingDefault(false);
  26. //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
  27. //分别调用无参报告,和带参报告
  28. if (args.Length == 0)
  29. {
  30. frmReportApp frmReportApp = new frmReportApp();
  31. Application.Run(frmReportApp);
  32. }
  33. else
  34. {
  35. frmReportApp frmReportApp = new frmReportApp(args);
  36. Application.Run(frmReportApp);
  37. }
  38. }
  39. static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
  40. {
  41. string dllname = args.Name.Split(',')[0];
  42. string path;
  43. if (dllname.Contains("CefSharp"))
  44. {
  45. path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"CefSharp");
  46. }
  47. else if (dllname.Contains("resource"))
  48. {
  49. return null;
  50. }
  51. else
  52. {
  53. path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"OTSCPPDll");
  54. }
  55. path = System.IO.Path.Combine(path, dllname);
  56. path = String.Format(@"{0}.dll", path);
  57. //if (path.Contains("CefSharp")) return null;
  58. return System.Reflection.Assembly.LoadFrom(path);
  59. }
  60. }
  61. }