Browse Source

[fix]

HuiZhou
fajiao 2 years ago
parent
commit
346d7ca0dd
  1. 5
      AutoWeightServer/Program.cs
  2. 3
      EC.Utils/CommonUtil.cs

5
AutoWeightServer/Program.cs

@ -2,6 +2,8 @@
using EC.Utils.Storage; using EC.Utils.Storage;
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.IO;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
@ -18,6 +20,7 @@ namespace EC.AutoWeightServer
[STAThread] [STAThread]
private static void Main() private static void Main()
{ {
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
@ -46,7 +49,6 @@ namespace EC.AutoWeightServer
{ {
string str = GetExceptionMsg(e.Exception, e.ToString()); string str = GetExceptionMsg(e.Exception, e.ToString());
LogUnit.Error("全局异常捕获 CSUI:\r\n" + str); 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); MessageBox.Show("操作执行异常,可尝试重新执行!\r\n\r\n" + e.Exception.Message, "UIException " + e.Exception.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1); Environment.Exit(1);
@ -56,7 +58,6 @@ namespace EC.AutoWeightServer
{ {
string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString()); string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString());
LogUnit.Error("全局异常捕获 CSUnUI:\r\n" + str); 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); 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); Environment.Exit(1);

3
EC.Utils/CommonUtil.cs

@ -222,9 +222,8 @@ namespace EC.Utils
public static string GetWorkDirectory() 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; return workDirectory;
} }
} }
} }
Loading…
Cancel
Save