Exemplo n.º 1
0
 private static void SubmitReport(Exception uncaughtException)
 {
     lock (WindowsErrorReporting.reportCreationLock)
     {
         if (uncaughtException == null)
         {
             throw new ArgumentNullException(nameof(uncaughtException));
         }
         WindowsErrorReporting.ReportInformation reportInformation = new WindowsErrorReporting.ReportInformation();
         reportInformation.dwSize              = Marshal.SizeOf((object)reportInformation);
         reportInformation.hProcess            = WindowsErrorReporting.hCurrentProcess;
         reportInformation.hwndParent          = WindowsErrorReporting.hwndMainWindow;
         reportInformation.wzApplicationName   = WindowsErrorReporting.applicationName;
         reportInformation.wzApplicationPath   = WindowsErrorReporting.applicationPath;
         reportInformation.wzConsentKey        = (string)null;
         reportInformation.wzDescription       = (string)null;
         reportInformation.wzFriendlyEventName = (string)null;
         WindowsErrorReporting.ReportHandle reportHandle;
         WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportCreate("PowerShell", WindowsErrorReporting.ReportType.WerReportCritical, reportInformation, out reportHandle));
         using (reportHandle)
         {
             WindowsErrorReporting.SetBucketParameters(reportHandle, uncaughtException);
             WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportAddDump(reportHandle, WindowsErrorReporting.hCurrentProcess, IntPtr.Zero, WindowsErrorReporting.DumpType.MiniDump, IntPtr.Zero, IntPtr.Zero, (WindowsErrorReporting.DumpFlags) 0));
             WindowsErrorReporting.SubmitResult result = WindowsErrorReporting.SubmitResult.ReportFailed;
             WindowsErrorReporting.SubmitFlags  flags  = WindowsErrorReporting.SubmitFlags.HonorRecovery | WindowsErrorReporting.SubmitFlags.HonorRestart | WindowsErrorReporting.SubmitFlags.AddRegisteredData | WindowsErrorReporting.SubmitFlags.OutOfProcess;
             if (WindowsErrorReporting.unattendedServerMode)
             {
                 flags |= WindowsErrorReporting.SubmitFlags.Queue;
             }
             WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportSubmit(reportHandle, WindowsErrorReporting.Consent.NotAsked, flags, out result));
             Environment.Exit((int)result);
         }
     }
 }
Exemplo n.º 2
0
 internal static extern int WerReportCreate([MarshalAs(UnmanagedType.LPWStr)] string pwzEventType, WindowsErrorReporting.ReportType repType, [MarshalAs(UnmanagedType.LPStruct)] WindowsErrorReporting.ReportInformation reportInformation, out WindowsErrorReporting.ReportHandle reportHandle);