| | |
| | | using log4net; |
| | | using Panuon.WPF.UI; |
| | | using System; |
| | | using System.IO; |
| | | using System.Reflection; |
| | | using System.Threading; |
| | | using System.Windows; |
| | | using WPFProject.Utils; |
| | |
| | | private static Mutex mutex; |
| | | private void Application_Startup(object sender, StartupEventArgs e) |
| | | { |
| | | mutex = new System.Threading.Mutex(true, "TestPlatform_OnlyRun_CRNS"); |
| | | mutex = new Mutex(true, "TestPlatform_OnlyRun_CRNS"); |
| | | if (mutex.WaitOne(0, false)) |
| | | { |
| | | AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; |
| | | |
| | | LangUtil.Load(); |
| | | SystemSetting.SystemSettingChanged += SystemSetting_SystemSettingChanged; |
| | | ToastHelper.Register(new MainToastHandler()); |
| | |
| | | } |
| | | } |
| | | |
| | | private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) |
| | | { |
| | | // 获取请求加载的程序集名称 |
| | | string assemblyName = new AssemblyName(args.Name).Name; |
| | | |
| | | string[] dirs = new string[] { "3rds", "Libs" }; |
| | | |
| | | foreach (string dir in dirs) |
| | | { |
| | | string dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dir, $"{assemblyName}.dll"); |
| | | if (File.Exists(dllPath)) |
| | | { |
| | | // 如果依赖 DLL 存在,则加载并返回它 |
| | | return Assembly.LoadFrom(dllPath); |
| | | } |
| | | } |
| | | // 否则返回 null |
| | | return null; |
| | | } |
| | | |
| | | private void SystemSetting_SystemSettingChanged(object sender, SystemSetting e) |
| | | { |
| | | LangUtil.LoadLang(); |