From a8e15280e124fcf9948c9fa434b7678863f7b42b Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 23 Oct 2019 12:20:52 -0600 Subject: [PATCH] Added workaround for missing function in .NET Std 2.0 --- Core/InteropServices/SafeIDispatch.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/InteropServices/SafeIDispatch.cs b/Core/InteropServices/SafeIDispatch.cs index 9c288cd9..b1c8196f 100644 --- a/Core/InteropServices/SafeIDispatch.cs +++ b/Core/InteropServices/SafeIDispatch.cs @@ -45,7 +45,11 @@ namespace Vanara.InteropServices var result = IntPtr.Zero; try { +#if NETSTANDARD2_0 + result = Marshal.GetComInterfaceForObject(target, typeof(IDispatch)); +#else result = Marshal.GetIDispatchForObject(target); +#endif } finally { @@ -55,5 +59,10 @@ namespace Vanara.InteropServices } return result; } + +#if NETSTANDARD2_0 + [ComImport, Guid("00020400-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] + private interface IDispatch { } +#endif } } \ No newline at end of file