Example #1
0
        /// <summary>
        /// Assembles the Watson bucket parameters.
        /// </summary>
        /// <param name="bucketParameters">Receives the bucket parameters.</param>
        /// <returns>A value indicating whether error details were successfully collected.</returns>
        /// <remarks>
        /// NOTE, this method should be called from the filter of an exception block.  Otherwise the runtime
        /// will not fill in the bucket parameters because there won't be a "current" exception.
        /// </remarks>
        private static bool TryGetBucketParameters(out Watson.BucketParameters bucketParameters)
        {
            bucketParameters = new Watson.BucketParameters();

            var runtimeHostType = Type.GetTypeFromCLSID(Watson.ClrRuntimeHostClassId);
            var runtime         = Activator.CreateInstance(runtimeHostType) as Watson.IClrRuntimeHost;

            if (runtime == null)
            {
                return(false);
            }

            Watson.IClrControl clrControl = runtime.GetCLRControl();
            if (clrControl == null)
            {
                return(false);
            }

            var errorManager = clrControl.GetCLRManager(ref Watson.ClrErrorReportingManagerInterfaceId) as Watson.IClrErrorReportingManager;

            if (errorManager == null)
            {
                return(false);
            }

            int errorCode = errorManager.GetBucketParametersForCurrentException(out bucketParameters);

            if (errorCode != 0)
            {
                Debug.Fail("GetBucketParametersForCurrentException failed");
                return(false);
            }

            // Make sure the event type is a traditional managed exception (clr20r3)
            if (!string.Equals(bucketParameters.EventType, "Clr20R3", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            // TODO:  Do we really need to muck with the version parameters?  Why aren't the clr20r3 settings good enough?
            return(true);
        }
Example #2
0
        /// <summary>
        /// Assembles the Watson bucket parameters.
        /// </summary>
        /// <param name="bucketParameters">Receives the bucket parameters.</param>
        /// <returns>A value indicating whether error details were successfully collected.</returns>
        /// <remarks>
        /// NOTE, this method should be called from the filter of an exception block.  Otherwise the runtime
        /// will not fill in the bucket parameters because there won't be a "current" exception.
        /// </remarks>
        private static bool TryGetBucketParameters(out Watson.BucketParameters bucketParameters)
        {
            bucketParameters = new Watson.BucketParameters();

            var runtimeHostType = Type.GetTypeFromCLSID(Watson.ClrRuntimeHostClassId);
            var runtime = Activator.CreateInstance(runtimeHostType) as Watson.IClrRuntimeHost;
            if (runtime == null)
            {
                return false;
            }

            Watson.IClrControl clrControl = runtime.GetCLRControl();
            if (clrControl == null)
            {
                return false;
            }

            var errorManager = clrControl.GetCLRManager(ref Watson.ClrErrorReportingManagerInterfaceId) as Watson.IClrErrorReportingManager;
            if (errorManager == null)
            {
                return false;
            }

            int errorCode = errorManager.GetBucketParametersForCurrentException(out bucketParameters);
            if (errorCode != 0)
            {
                Debug.Fail("GetBucketParametersForCurrentException failed");
                return false;
            }

            // Make sure the event type is a traditional managed exception (clr20r3)
            if (!string.Equals(bucketParameters.EventType, "Clr20R3", StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            // TODO:  Do we really need to muck with the version parameters?  Why aren't the clr20r3 settings good enough?
            return true;
        }