|
|
@ -4,8 +4,10 @@ using System.Collections.Generic; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Configuration; |
|
|
|
using System.Data; |
|
|
|
using System.Globalization; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
@ -18,6 +20,43 @@ namespace DyeingComputer |
|
|
|
/// </summary>
|
|
|
|
public partial class App : Application |
|
|
|
{ |
|
|
|
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) |
|
|
|
{ |
|
|
|
Assembly executingAssembly = Assembly.GetExecutingAssembly(); |
|
|
|
var executingAssemblyName = executingAssembly.GetName(); |
|
|
|
var resName = executingAssemblyName.Name + ".resources"; |
|
|
|
|
|
|
|
AssemblyName assemblyName = new AssemblyName(args.Name); string path = ""; |
|
|
|
if (resName == assemblyName.Name) |
|
|
|
{ |
|
|
|
path = executingAssemblyName.Name + ".g.resources"; ; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
path = assemblyName.Name + ".dll"; |
|
|
|
if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false) |
|
|
|
{ |
|
|
|
path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
using (Stream stream = executingAssembly.GetManifestResourceStream(path)) |
|
|
|
{ |
|
|
|
if (stream == null) |
|
|
|
return null; |
|
|
|
|
|
|
|
byte[] assemblyRawBytes = new byte[stream.Length]; |
|
|
|
stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length); |
|
|
|
return Assembly.Load(assemblyRawBytes); |
|
|
|
} |
|
|
|
} |
|
|
|
protected override void OnStartup(StartupEventArgs e) |
|
|
|
{ |
|
|
|
base.OnStartup(e); |
|
|
|
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; |
|
|
|
this.DispatcherUnhandledException += App_DispatcherUnhandledException; |
|
|
|
} |
|
|
|
|
|
|
|
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini"); |
|
|
|
|
|
|
|
public App() |
|
|
@ -46,12 +85,12 @@ namespace DyeingComputer |
|
|
|
//return Container.Resolve<MainWindow>();
|
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnStartup(StartupEventArgs e) //跟踪报错信息
|
|
|
|
{ |
|
|
|
base.OnStartup(e); |
|
|
|
//UI线程的异常捕捉
|
|
|
|
this.DispatcherUnhandledException += App_DispatcherUnhandledException; |
|
|
|
} |
|
|
|
// protected override void OnStartup(StartupEventArgs e) //跟踪报错信息
|
|
|
|
// {
|
|
|
|
// base.OnStartup(e);
|
|
|
|
// //UI线程的异常捕捉
|
|
|
|
// this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
|
|
|
// }
|
|
|
|
|
|
|
|
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
|
|
|
{ |
|
|
|