diff --git a/AutoWeightServer/Program.cs b/AutoWeightServer/Program.cs index 35d240d..9596ac4 100644 --- a/AutoWeightServer/Program.cs +++ b/AutoWeightServer/Program.cs @@ -2,6 +2,8 @@ using EC.Utils.Storage; using System; using System.Data.SqlClient; +using System.IO; +using System.Reflection; using System.Text; using System.Threading; using System.Windows.Forms; @@ -18,6 +20,7 @@ namespace EC.AutoWeightServer [STAThread] private static void Main() { + Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); @@ -46,7 +49,6 @@ namespace EC.AutoWeightServer { string str = GetExceptionMsg(e.Exception, e.ToString()); LogUnit.Error("全局异常捕获 CSUI:\r\n" + str); - // logService.WriteDbLog(4, "9", "卷丝-全局异常捕获", "CSUI", false, str); MessageBox.Show("操作执行异常,可尝试重新执行!\r\n\r\n" + e.Exception.Message, "UIException " + e.Exception.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); @@ -56,7 +58,6 @@ namespace EC.AutoWeightServer { string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString()); LogUnit.Error("全局异常捕获 CSUnUI:\r\n" + str); - // logService.WriteDbLog(4, "9", "卷丝-全局异常捕获", "CSUnUI", false, str); MessageBox.Show("操作执行异常,程序即将关闭!\r\n\r\n" + (e.ExceptionObject as Exception)?.Message, "UnUIException " + (e.ExceptionObject as Exception)?.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); diff --git a/EC.Utils/CommonUtil.cs b/EC.Utils/CommonUtil.cs index 8f9fd6d..9405212 100644 --- a/EC.Utils/CommonUtil.cs +++ b/EC.Utils/CommonUtil.cs @@ -222,9 +222,8 @@ namespace EC.Utils public static string GetWorkDirectory() { - workDirectory = string.IsNullOrEmpty(workDirectory) ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) :workDirectory; + workDirectory = string.IsNullOrEmpty(workDirectory) ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) : workDirectory; return workDirectory; } - } } \ No newline at end of file