From 01cc22e8710c4efffb35fd1e206c646dc3cbc210 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 27 Jun 2014 13:03:11 +0200 Subject: [PATCH] Noticed that my change for BUG-1616 doesn't help, as the exception in not a ComException, so I rewrote it to use a catch statement. [skip ci] --- GreenshotPlugin/Interop/COMWrapper.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/GreenshotPlugin/Interop/COMWrapper.cs b/GreenshotPlugin/Interop/COMWrapper.cs index 4bc42e977..956a79915 100644 --- a/GreenshotPlugin/Interop/COMWrapper.cs +++ b/GreenshotPlugin/Interop/COMWrapper.cs @@ -38,8 +38,6 @@ namespace Greenshot.Interop { private const int CO_E_CLASSSTRING = -2147221005; public const int RPC_E_CALL_REJECTED = unchecked((int)0x80010001); public const int RPC_E_FAIL = unchecked((int)0x80004005); - public const int RPC_E_COM_SEPARATED_RCW = unchecked((int)0x80131527); - #region Private Data @@ -673,6 +671,10 @@ namespace Greenshot.Interop { try { returnValue = invokeType.InvokeMember(methodName, flags, null, invokeObject, args, argModifiers, null, null); break; + } catch (InvalidComObjectException icoEx) { + // Should assist BUG-1616 and others + LOG.WarnFormat("COM object {0} has been separated from its underlying RCW cannot be used. The COM object was released while it was still in use on another thread.", _InterceptType.FullName); + return new ReturnMessage(icoEx, callMessage); } catch (Exception ex) { // Test for rejected COMException comEx = ex as COMException; @@ -693,9 +695,6 @@ namespace Greenshot.Interop { continue; } } - if (comEx != null && comEx.ErrorCode == RPC_E_COM_SEPARATED_RCW) { - LOG.WarnFormat("COM object {0} has been separated from its underlying RCW cannot be used. The COM object was released while it was still in use on another thread.", _InterceptType.FullName); - } // Not rejected OR pressed cancel return new ReturnMessage(ex, callMessage); }