posted this in Apache, c#, IIS on April 13th, 2012 Nathan Bridgewater explained how to configure multiple reverse proxies properly with apache and IIS (without losing original domain name). I’m reposting this for myself to keep a record of this fine work.
multiple reverse proxy host broken iis serving up local server name instead of the ServerName that was originally passed to it. How to . . . → Read More: multiple reverse proxy host broken
posted this in c# on January 21st, 2011 how to generate a dump file on application crash in c#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
using System; using System.Collections.Generic; using System.Windows.Forms; using System.Runtime.InteropServices; using System.IO; namespace DBGHelp_Sample { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } public static class MINIDUMP_TYPE { public const int MiniDumpNormal = 0x00000000; public const int MiniDumpWithDataSegs = 0x00000001; public const int MiniDumpWithFullMemory = 0x00000002; public const int MiniDumpWithHandleData = 0x00000004; public const int MiniDumpFilterMemory = 0x00000008; public const int MiniDumpScanMemory = 0x00000010; public const int MiniDumpWithUnloadedModules = 0x00000020; public const int MiniDumpWithIndirectlyReferencedMemory = 0x00000040; public const int MiniDumpFilterModulePaths = 0x00000080; public const int MiniDumpWithProcessThreadData = 0x00000100; public const int MiniDumpWithPrivateReadWriteMemory = 0x00000200; public const int MiniDumpWithoutOptionalData = 0x00000400; public const int MiniDumpWithFullMemoryInfo = 0x00000800; public const int MiniDumpWithThreadInfo = 0x00001000; public const int MiniDumpWithCodeSegs = 0x00002000; } [DllImport("dbghelp.dll")] public static extern bool MiniDumpWriteDump(IntPtr hProcess, Int32 ProcessId, IntPtr hFile, int DumpType, IntPtr ExceptionParam, IntPtr UserStreamParam, IntPtr CallackParam); private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { CreateMiniDump(); } private static void CreateMiniDump() { using(FileStream fs = new FileStream("UnhandledDump.dmp", FileMode.Create)) { using(System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess()) { MiniDumpWriteDump(process.Handle, process.Id, fs.SafeFileHandle.DangerousGetHandle(), MINIDUMP_TYPE.MiniDumpNormal, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } } } } } |
Another Option:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
using System; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; namespace ConsoleApplication29 { class Program { [Flags] enum MINIDUMP_TYPE: uint { MiniDumpNormal = 0x00000000, MiniDumpWithDataSegs = 0x00000001, MiniDumpWithFullMemory = 0x00000002, MiniDumpWithHandleData = 0x00000004, MiniDumpFilterMemory = 0x00000008, MiniDumpScanMemory = 0x00000010, MiniDumpWithUnloadedModules = 0x00000020, MiniDumpWithIndirectlyReferencedMemory = 0x00000040, MiniDumpFilterModulePaths = 0x00000080, MiniDumpWithProcessThreadData = 0x00000100, MiniDumpWithPrivateReadWriteMemory = 0x00000200, MiniDumpWithoutOptionalData = 0x00000400, MiniDumpWithFullMemoryInfo = 0x00000800, MiniDumpWithThreadInfo = 0x00001000, MiniDumpWithCodeSegs = 0x00002000, MiniDumpWithoutAuxiliaryState = 0x00004000, MiniDumpWithFullAuxiliaryState = 0x00008000, MiniDumpWithPrivateWriteCopyMemory = 0x00010000, MiniDumpIgnoreInaccessibleMemory = 0x00020000, MiniDumpWithTokenInformation = 0x00040000 }; [DllImport ("DbgHelp.dll", SetLastError = true)] [Return: MarshalAs (UnmanagedType. Bool)] static extern bool MiniDumpWriteDump ( IntPtr hProcess, int ProcessId, IntPtr hFile, MINIDUMP_TYPE DumpType, IntPtr ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam ); static void Main (string [] args) { using (var process = Process. GetProcessesByName ("idaq") [0]) using (var file = File. Open ("mem.dmp", FileMode. Create, FileAccess. Write)) { var dumpType = MINIDUMP_TYPE. MiniDumpNormal; if (! MiniDumpWriteDump ( process. Handle, process. Id, file. Handle, dumpType, IntPtr. Zero, IntPtr. Zero, IntPtr. Zero) ) throw new Win32Exception (Marshal. GetLastWin32Error ()); } } } } |
|
|