Program.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. //static System.Reflection.Assembly CurrentDomain_ResourcesAssemblyResolve(object sender, ResolveEventArgs args)
  61. //{
  62. // string dllName = args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll", "");
  63. // dllName = dllName.Replace(".", "_");
  64. // if (dllName.EndsWith("_resources")) return null;
  65. // System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());
  66. // byte[] bytes = (byte[])rm.GetObject(dllName);
  67. // return System.Reflection.Assembly.Load(bytes);
  68. //}
  69. }
  70. }