Author: joncham
Date: 2007-05-25 16:21:45 -0400 (Fri, 25 May 2007)
New Revision: 77971
Modified:
trunk/mcs/class/corlib/Mono.Interop/ChangeLog
trunk/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs
trunk/mcs/class/corlib/System/ChangeLog
trunk/mcs/class/corlib/System/__ComObject.cs
Log:
2007-05-25 Jonathan Chambers <[EMAIL PROTECTED]>
Add overload to GetInterface to allow
not throwing exceptions. Fixes as and is operators for COM objects.
Modified: trunk/mcs/class/corlib/Mono.Interop/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Mono.Interop/ChangeLog 2007-05-25 20:20:09 UTC
(rev 77970)
+++ trunk/mcs/class/corlib/Mono.Interop/ChangeLog 2007-05-25 20:21:45 UTC
(rev 77971)
@@ -1,3 +1,8 @@
+2007-05-25 Jonathan Chambers <[EMAIL PROTECTED]>
+
+ * ComInteropProxy.cs: Call __ComObject.GetInterface overload
+ that does not throw exception. Fixes as and is operators for COM
objects.
+
2007-02-08 Jonathan Chambers <[EMAIL PROTECTED]>
* ComInteropProxy.cs: Moved some code to unmanaged and cleanup some
things.
Modified: trunk/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs 2007-05-25
20:20:09 UTC (rev 77970)
+++ trunk/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs 2007-05-25
20:21:45 UTC (rev 77971)
@@ -120,7 +120,7 @@
if ((fromType.Attributes & TypeAttributes.Import) == 0)
return false;
- if (co.GetInterface (fromType) == IntPtr.Zero)
+ if (co.GetInterface (fromType, false) == IntPtr.Zero)
return false;
return true;
Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog 2007-05-25 20:20:09 UTC (rev
77970)
+++ trunk/mcs/class/corlib/System/ChangeLog 2007-05-25 20:21:45 UTC (rev
77971)
@@ -1,3 +1,8 @@
+2007-05-25 Jonathan Chambers <[EMAIL PROTECTED]>
+
+ * __ComObject.cs: Add overload to GetInterface to allow
+ not throwing exceptions. Fixes as and is operators for COM objects.
+
2007-05-23 Atsushi Enomoto <[EMAIL PROTECTED]>
* Array.cs : reverting Array.cs fixes since the runtime depends on
Modified: trunk/mcs/class/corlib/System/__ComObject.cs
===================================================================
--- trunk/mcs/class/corlib/System/__ComObject.cs 2007-05-25 20:20:09 UTC
(rev 77970)
+++ trunk/mcs/class/corlib/System/__ComObject.cs 2007-05-25 20:21:45 UTC
(rev 77971)
@@ -109,8 +109,7 @@
throw new COMException ("Could not find base COM type
for type " + t.ToString());
}
- internal IntPtr GetInterface(Type t)
- {
+ internal IntPtr GetInterface (Type t, bool throwException) {
CheckIUnknown ();
IntPtr pItf = FindInterface (this, t);
if (pItf != IntPtr.Zero) {
@@ -120,11 +119,18 @@
Guid iid = t.GUID;
IntPtr ppv;
int hr = Marshal.QueryInterface (iunknown, ref iid, out
ppv);
- Marshal.ThrowExceptionForHR (hr);
- AddInterface (this, t, ppv);
+ if (throwException)
+ Marshal.ThrowExceptionForHR (hr);
+ if (hr > 0 && ppv != IntPtr.Zero)
+ AddInterface (this, t, ppv);
return ppv;
}
+ internal IntPtr GetInterface(Type t)
+ {
+ return GetInterface (t, true);
+ }
+
private void CheckIUnknown ()
{
if (iunknown == IntPtr.Zero)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches