public WrapperSEHException( string message, SEHException inner ) : base( message, inner ) { this.HResult = inner.ErrorCode; }
/// <summary> /// Get the RPC Exception Code /// </summary> /// <param name="e"> /// Exception object</param> /// <returns>Returns the RPC error code</returns> public static uint RpcExceptionCode(SEHException e) { uint errorCode = 0; Type sehType = typeof(SEHException); FieldInfo xcodeField = sehType.BaseType.BaseType.BaseType.GetField("_xcode", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (xcodeField != null) { int code = (int)xcodeField.GetValue(e); errorCode = (uint)code; } return errorCode; }
public void TestSEHException() { var value = new SEHException( "Message" ); try { ExceptionDispatchInfo.Capture( value ).Throw(); } catch ( SEHException ex ) { Assert.That( ex, Is.Not.SameAs( value ) ); Assert.That( ex.ErrorCode, Is.EqualTo( value.ErrorCode ) ); } }