using System; using System.Reflection; using System.Windows.Forms; namespace OTSIncAReportApp { static class Program { /// /// 应用程序的主入口点。 /// /// static Program() { string privatepath = "System;Common;DevExpress;FEIAutoScript;SQLiteDll;OxfordExtender;OTSCPPDll;OpenCvSharp;CefSharp"; AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", privatepath); AppDomain.CurrentDomain.SetData("BINPATH_PROBE_ONLY", privatepath); var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static); var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance); m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privatepath }); } [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; //分别调用无参报告,和带参报告 if (args.Length == 0) { frmReportApp frmReportApp = new frmReportApp(); Application.Run(frmReportApp); } else { frmReportApp frmReportApp = new frmReportApp(args); Application.Run(frmReportApp); } } static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string dllname = args.Name.Split(',')[0]; string path; if (dllname.Contains("CefSharp")) { path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"CefSharp"); } else if (dllname.Contains("resource")) { return null; } else { path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"OTSCPPDll"); } path = System.IO.Path.Combine(path, dllname); path = String.Format(@"{0}.dll", path); //if (path.Contains("CefSharp")) return null; return System.Reflection.Assembly.LoadFrom(path); } } }