コード例 #1
0
 private static string TruncateExeName(string nameOfExe, int maxLength)
 {
     nameOfExe = nameOfExe.Trim();
     if (nameOfExe.Length > maxLength && nameOfExe.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
     {
         nameOfExe = nameOfExe.Substring(0, nameOfExe.Length - ".exe".Length);
     }
     return(WindowsErrorReporting.TruncateBucketParameter(nameOfExe, maxLength));
 }
コード例 #2
0
 private static string TruncateExceptionType(string exceptionType, int maxLength)
 {
     if (exceptionType.Length > maxLength && exceptionType.EndsWith("Exception", StringComparison.OrdinalIgnoreCase))
     {
         exceptionType = exceptionType.Substring(0, exceptionType.Length - "Exception".Length);
     }
     if (exceptionType.Length > maxLength)
     {
         exceptionType = WindowsErrorReporting.TruncateTypeName(exceptionType, maxLength);
     }
     return(WindowsErrorReporting.TruncateBucketParameter(exceptionType, maxLength));
 }
コード例 #3
0
        private static string StackFrame2BucketParameter(StackFrame frame, int maxLength)
        {
            MethodBase method = frame.GetMethod();

            if (method == null)
            {
                return(string.Empty);
            }
            Type declaringType = method.DeclaringType;

            if (declaringType == null)
            {
                return(WindowsErrorReporting.TruncateBucketParameter(method.Name, maxLength));
            }
            string fullName = declaringType.FullName;
            string str      = "." + method.Name;

            return(WindowsErrorReporting.TruncateBucketParameter((maxLength <= str.Length ? WindowsErrorReporting.TruncateTypeName(fullName, 1) : WindowsErrorReporting.TruncateTypeName(fullName, maxLength - str.Length)) + str, maxLength));
        }
コード例 #4
0
        private static void SetBucketParameters(
            WindowsErrorReporting.ReportHandle reportHandle,
            Exception uncaughtException)
        {
            Exception exception = uncaughtException;

            while (exception.InnerException != null)
            {
                exception = exception.InnerException;
            }
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.NameOfExe, WindowsErrorReporting.TruncateExeName(WindowsErrorReporting.nameOfExe, 20));
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.FileVersionOfSystemManagementAutomation, WindowsErrorReporting.TruncateBucketParameter(WindowsErrorReporting.versionOfPowerShellLibraries, 16));
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.InnermostExceptionType, WindowsErrorReporting.TruncateExceptionType(exception.GetType().FullName, 40));
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.OutermostExceptionType, WindowsErrorReporting.TruncateExceptionType(uncaughtException.GetType().FullName, 40));
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.DeepestFrame, WindowsErrorReporting.GetDeepestFrame(uncaughtException, 50));
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.DeepestPowerShellFrame, WindowsErrorReporting.GetDeepestPowerShellFrame(uncaughtException, 50));
            WindowsErrorReporting.SetBucketParameter(reportHandle, WindowsErrorReporting.BucketParameterId.ThreadName, WindowsErrorReporting.TruncateBucketParameter(WindowsErrorReporting.GetThreadName(), 20));
        }