diff options
author | Faizur Rahman <shrah@microsoft.com> | 2017-06-07 22:17:04 +0300 |
---|---|---|
committer | Faizur Rahman <shrah@microsoft.com> | 2017-06-07 22:17:04 +0300 |
commit | 026518036cb65aeba0c8ce7b68b9dcf58fd95b62 (patch) | |
tree | 119b09b6dcddbe3a34058dc28d283dc845de6772 /src/System.Private.Reflection.Core | |
parent | 721e76d5beb52d0d5ed854d8a7d39e5846da12ed (diff) |
Implement Marshal.GetTypeFromCLSID
This change fixes the issue described here https://github.com/dotnet/corert/issues/1764. I have verified the customer issue with MBN and it works with this change.
[tfs-changeset: 1660962]
Diffstat (limited to 'src/System.Private.Reflection.Core')
-rw-r--r-- | src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeClsIdNullaryConstructorInfo.cs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeClsIdNullaryConstructorInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeClsIdNullaryConstructorInfo.cs index e9f59b1fe..5fa00d9c2 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeClsIdNullaryConstructorInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/RuntimeClsIdNullaryConstructorInfo.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Reflection.Runtime.General; using System.Reflection.Runtime.TypeInfos; using System.Reflection.Runtime.ParameterInfos; +using System.Runtime.InteropServices; using Internal.Reflection.Core.Execution; @@ -58,7 +59,22 @@ namespace System.Reflection.Runtime.MethodInfos Guid clsid = _declaringType.GUID; string server = _declaringType.Server; - throw new NotImplementedException(); // TODO: https://github.com/dotnet/corert/issues/1764 - Make the call out to Interop to create an RCW from the supplied CLSID and server. + IntPtr pItf = IntPtr.Zero; + try + { + pItf = McgMarshal.CoCreateInstanceEx(clsid, server); + + // CoCreateInstanceEx will throw exception if it fails to + // create an instance. + Debug.Assert(pItf != IntPtr.Zero); + + return Marshal.GetObjectForIUnknown(pItf); + } + finally + { + if (pItf != IntPtr.Zero) + Marshal.Release(pItf); + } } public sealed override MethodBase MetadataDefinitionMethod { get { throw new NotSupportedException(); } } |