Write() public static method

public static Write ( SafeHandle fileHandle, Option dumpType ) : bool
fileHandle System.Runtime.InteropServices.SafeHandle
dumpType Option
return bool
コード例 #1
0
        /// <summary>
        ///     Deal with sending the error to the error reporting service and saving the dump to the harddrive if needed
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="ex"></param>
        public static void handleException(string msg, Exception ex)
        {
            if (m_saveCrashDumps && Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                // Log exception to disk
                try
                {
                    if (!Directory.Exists(m_crashDir))
                    {
                        Directory.CreateDirectory(m_crashDir);
                    }

                    string log = Path.Combine(m_crashDir, Util.GetUniqueFilename("crashDump" +
                                                                                 DateTime.Now.Day + DateTime.Now.Month +
                                                                                 DateTime.Now.Year + ".mdmp"));
                    using (FileStream fs = new FileStream(log, FileMode.Create, FileAccess.ReadWrite, FileShare.Write))
                    {
                        MiniDump.Write(fs.SafeFileHandle,
                                       MiniDump.Option.WithThreadInfo | MiniDump.Option.WithProcessThreadData |
                                       MiniDump.Option.WithUnloadedModules | MiniDump.Option.WithHandleData |
                                       MiniDump.Option.WithDataSegs | MiniDump.Option.WithCodeSegs,
                                       MiniDump.ExceptionInfo.Present);
                    }
                }
                catch (Exception e2)
                {
                    MainConsole.Instance.ErrorFormat("[CRASH LOGGER CRASHED]: {0}", e2);
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///     Deal with sending the error to the error reporting service and saving the dump to the hard-drive if needed
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="ex"></param>
        public static void HandleCrashException(string msg, Exception ex)
        {
            //if (m_saveCrashDumps && Environment.OSVersion.Platform == PlatformID.Win32NT)
            // 20160323 -greythane - not sure why this will not work on *nix as well?
            // 20160408 -EmperorStarfinder - This appears to not work on either Windows or Nix.
            // Maybe consider removing the saveCrashDumps as it appears it is writing it to the
            // logs for Universe.Server and Universe consoles already?
            if (m_saveCrashDumps)
            {
                // Log exception to disk
                try {
                    if (!Directory.Exists(m_crashDir))
                    {
                        Directory.CreateDirectory(m_crashDir);
                    }

                    string log = Path.Combine(m_crashDir, Util.GetUniqueFilename("CrashDump" +
                                                                                 DateTime.Now.Day + DateTime.Now.Month +
                                                                                 DateTime.Now.Year + ".mdmp"));
                    using (FileStream fs = new FileStream(log, FileMode.Create, FileAccess.ReadWrite, FileShare.Write)) {
                        MiniDump.Write(fs.SafeFileHandle,
                                       MiniDump.Option.WithThreadInfo | MiniDump.Option.WithProcessThreadData |
                                       MiniDump.Option.WithUnloadedModules | MiniDump.Option.WithHandleData |
                                       MiniDump.Option.WithDataSegs | MiniDump.Option.WithCodeSegs,
                                       MiniDump.ExceptionInfo.Present);
                    }
                } catch (Exception e2) {
                    MainConsole.Instance.ErrorFormat("[Crash logger crashed]: {0}", e2);
                }
            }
        }