I have similar problem :
I am creating a crash dump file for divide by zero exception in C#.
When I write a sample console application to generate it, it creates the
dump file successfully, but when i tried to use the same code in different
application in the same machine, then it creates a dumpfile of zero bytes.
Sample code for your reference :
using System;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;
using System.Globalization;
public class CallMyHelloWorld
{
public static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=
new
UnhandledExceptionEventHandler(CurrentDomainUnhandledException);
int i = 0;
int j = 10 / i;
}
public static class MINIDUMPTYPE
{
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 CurrentDomainUnhandledException(
object sender, UnhandledExceptionEventArgs e)
{
CreateMiniDump();
}
private static void CreateMiniDump()
{
DateTime endTime = DateTime.Now;
string dt = endTime.ToString("yyyy.MM.dd.HH.mm.ss",
DateTimeFormatInfo.InvariantInfo);
string dumpFileName = "C:\\HelloWorldDump" + dt +".dmp";
FileStream fs = new FileStream(dumpFileName, FileMode.Create);
System.Diagnostics.Process process =
System.Diagnostics.Process.GetCurrentProcess();
MiniDumpWriteDump(
process.Handle, process.Id,
fs.SafeFileHandle.DangerousGetHandle(),
MINIDUMPTYPE.MiniDumpWithFullMemory, IntPtr.Zero, IntPtr.Zero,
IntPtr.Zero);
}
}
Can anyone help me, what might be the problem, what might be the reason for
the same code running correctly in one application and failing when run
integrated in different application (I mean it creates empty crash dump file)
?
Please help.
Thanking you in advance
Post by Dennis MikhailitskyOn the machine where dumps are generated fine, I have multiple
dbghelp.dll files. The one from windows\system32 is 5.2.3790.1830. On
the machine where empty dumps are created, the version is
5.2.3790.3959. Usually the crashes are caused by the wrong pointer
access, so I believe it should not be too destructive for the
application, yet often times crash dumps are empty.
Post by Marc ShermanAre you using the same version of dbghelp.dll in both cases?
Also, many recommend doing the minimum in your exception handler and having
another "healthy" process call MiniDumpWriteDump on the crashing process.
Your crashing process may be so corrupt that it can't write the dump file..
The most you would want to do in your exception handler is set an event that
would cause the other process to generate the dump file.
Marc
Post by Dennis MikhailitskyHello,
I keep experiencing this problem when MiniDumpWriteDump generates
empty crash dumps. I have a program that calls this function in
exception handlers. On 1 machine all crash dumps are generated
perfectly well, while on another machine in 99% cases crash dumps
generated end up being empty (not a single byte is written to the dump
file). The very same program is being used in both cases. The OS is
Win 2003 Server, SP2. Any suggestions would be highly appreciated.
Thanks in advance.