static void mCurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { ExceptionForm asf = new ExceptionForm(e.ExceptionObject as Exception); asf.Show(); }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { ExceptionForm asf = new ExceptionForm(e.Exception); asf.Show(); }
private void Form1_Activated(object sender, EventArgs e) { if (actived) return; actived = true; Assembly CoreAsm = null; string asmFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + ".wischilauncher" + Path.DirectorySeparatorChar + "internal.dat"; #if DEBUG asmFile = @"C:\Users\Christian\Documents\Visual Studio 2010\Projects\WischiLauncherSVN\WischiLauncherCore\bin\Debug\WischisMinecraftLauncherCoreDLL.exe"; #endif Version LocalVersion = new Version(0, 0, 0); Version OnlineVersion = new Version(0, 0, 0); LoadingText = "Ermittle Lokale Version..."; if (File.Exists(asmFile)) //falls datei existiert dann Verison { try { byte[] AsmMemory = File.ReadAllBytes(asmFile); Assembly OldAsm = Assembly.Load(AsmMemory); LocalVersion = OldAsm.GetName().Version; } catch { LocalVersion = new Version(0, 0, 0); } } LoadingText = "Ermittle Online Version..."; //Get onlineVersion try { HttpWebRequest Versionrequest = (HttpWebRequest)WebRequest.Create("http://dev.wischenbart.org/minecraft/version.php"); Versionrequest.Proxy = null; Stream Response = Versionrequest.GetResponse().GetResponseStream(); string Vstring = new StreamReader(Response).ReadToEnd(); OnlineVersion = new Version(Vstring); } catch { OnlineVersion = new Version(0, 0, 0); } if (LocalVersion < OnlineVersion) { LoadingText = "Update WMCL..."; FileStream corefile = null; try { HttpWebRequest NewCoreRequest = (HttpWebRequest)WebRequest.Create("http://dev.wischenbart.org/minecraft/internal.dat"); NewCoreRequest.Proxy = null; Stream CoreFileStream = NewCoreRequest.GetResponse().GetResponseStream(); string dir = Path.GetDirectoryName(asmFile); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); corefile = File.Open(asmFile, FileMode.OpenOrCreate, FileAccess.Write); byte[] buffer = new byte[1024 * 1024]; int read; while ((read = CoreFileStream.Read(buffer, 0, buffer.Length)) > 0) { corefile.Write(buffer, 0, read); } } catch { } finally { if (corefile != null) corefile.Close(); } } LoadingText = "Load WMCL Core..."; CoreAsm = null; try { CoreAsm = Assembly.LoadFile(asmFile); } catch { MessageBox.Show("CoreDaten konnten nicht geladen werden."); Environment.Exit(-4); } LoadingText = "Start..."; MethodInfo Entry = CoreAsm.EntryPoint; if (Entry == null) { MessageBox.Show("Einstiegspunkt wurde nicht gefunden."); Environment.Exit(-3); } this.Hide(); //MethodInfo start try { Entry.Invoke(null, null); } catch(Exception ex) { ExceptionForm asf = new ExceptionForm(ex); asf.Show(); } }
private void Form1_Activated(object sender, EventArgs e) { if (actived) { return; } actived = true; Assembly CoreAsm = null; string asmFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + ".wischilauncher" + Path.DirectorySeparatorChar + "internal.dat"; #if DEBUG asmFile = @"C:\Users\Christian\Documents\Visual Studio 2010\Projects\WischiLauncherSVN\WischiLauncherCore\bin\Debug\WischisMinecraftLauncherCoreDLL.exe"; #endif Version LocalVersion = new Version(0, 0, 0); Version OnlineVersion = new Version(0, 0, 0); LoadingText = "Ermittle Lokale Version..."; if (File.Exists(asmFile)) //falls datei existiert dann Verison { try { byte[] AsmMemory = File.ReadAllBytes(asmFile); Assembly OldAsm = Assembly.Load(AsmMemory); LocalVersion = OldAsm.GetName().Version; } catch { LocalVersion = new Version(0, 0, 0); } } LoadingText = "Ermittle Online Version..."; //Get onlineVersion try { HttpWebRequest Versionrequest = (HttpWebRequest)WebRequest.Create("http://dev.wischenbart.org/minecraft/version.php"); Versionrequest.Proxy = null; Stream Response = Versionrequest.GetResponse().GetResponseStream(); string Vstring = new StreamReader(Response).ReadToEnd(); OnlineVersion = new Version(Vstring); } catch { OnlineVersion = new Version(0, 0, 0); } if (LocalVersion < OnlineVersion) { LoadingText = "Update WMCL..."; FileStream corefile = null; try { HttpWebRequest NewCoreRequest = (HttpWebRequest)WebRequest.Create("http://dev.wischenbart.org/minecraft/internal.dat"); NewCoreRequest.Proxy = null; Stream CoreFileStream = NewCoreRequest.GetResponse().GetResponseStream(); string dir = Path.GetDirectoryName(asmFile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } corefile = File.Open(asmFile, FileMode.OpenOrCreate, FileAccess.Write); byte[] buffer = new byte[1024 * 1024]; int read; while ((read = CoreFileStream.Read(buffer, 0, buffer.Length)) > 0) { corefile.Write(buffer, 0, read); } } catch { } finally { if (corefile != null) { corefile.Close(); } } } LoadingText = "Load WMCL Core..."; CoreAsm = null; try { CoreAsm = Assembly.LoadFile(asmFile); } catch { MessageBox.Show("CoreDaten konnten nicht geladen werden."); Environment.Exit(-4); } LoadingText = "Start..."; MethodInfo Entry = CoreAsm.EntryPoint; if (Entry == null) { MessageBox.Show("Einstiegspunkt wurde nicht gefunden."); Environment.Exit(-3); } this.Hide(); //MethodInfo start try { Entry.Invoke(null, null); } catch (Exception ex) { ExceptionForm asf = new ExceptionForm(ex); asf.Show(); } }