using System; using System.Reflection; using System.Windows.Forms; namespace OTSMeasureApp { 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() { if (!System.Diagnostics.Debugger.IsAttached) { //判断是否有授权 //var reg = new CRegistration(); //if (!reg.RegistrationVerification()) //{ // MessageBox.Show("Error: missing authorization"); // System.Environment.Exit(0); // return; //} } //--------------------------只运行一个测量程序-------------------------------- bool flag = false; System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OTSIncAMeasureApp", out flag); //第一个参数:true--给调用线程赋予互斥体的初始所属权 //第一个参数:互斥体的名称 //第三个参数:返回值,如果调用线程已被授予互斥体的初始所属权,则返回true if (!flag) { MessageBox.Show("Only one measurement program can be run!", "please confirm", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0);//退出程序 } //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new OTSIncAMeasureAppForm()); } //static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) //{ // string dllname = args.Name.Split(',')[0]; // string path; // if (dllname.Contains("OINA")) // { // if (dllname.Contains("resource")) // { // return null; // } // if (dllname.Contains("XmlSerialize")) // { // return null; // } // path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"OxfordExtender"); //} // 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); //} } }