Example #1
0
 public static unsafe ComActivationContext Create(ref ComActivationContextInternal cxtInt)
 {
     return(new ComActivationContext()
     {
         ClassId = cxtInt.ClassId,
         InterfaceId = cxtInt.InterfaceId,
         AssemblyPath = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyPathBuffer)) !,
         AssemblyName = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyNameBuffer)) !,
         TypeName = Marshal.PtrToStringUni(new IntPtr(cxtInt.TypeNameBuffer)) !
     });
Example #2
0
        public static unsafe ComActivationContext Create(ref ComActivationContextInternal cxtInt)
        {
#if FEATURE_COMINTEROP_UNMANAGED_ACTIVATION
            return(new ComActivationContext()
            {
                ClassId = cxtInt.ClassId,
                InterfaceId = cxtInt.InterfaceId,
                AssemblyPath = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyPathBuffer)) !,
                AssemblyName = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyNameBuffer)) !,
                TypeName = Marshal.PtrToStringUni(new IntPtr(cxtInt.TypeNameBuffer)) !
            });
Example #3
0
        public static unsafe ComActivationContext Create(ref ComActivationContextInternal cxtInt)
        {
            if (!Marshal.IsBuiltInComSupported)
            {
                throw new NotSupportedException(SR.NotSupported_COM);
            }

            return(new ComActivationContext()
            {
                ClassId = cxtInt.ClassId,
                InterfaceId = cxtInt.InterfaceId,
                AssemblyPath = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyPathBuffer)) !,
                AssemblyName = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyNameBuffer)) !,
                TypeName = Marshal.PtrToStringUni(new IntPtr(cxtInt.TypeNameBuffer)) !
            });
Example #4
0
        public unsafe static int GetClassFactoryForTypeInternal(ref ComActivationContextInternal cxtInt)
        {
            if (IsLoggingEnabled())
            {
                Log(
                    $@"{nameof(GetClassFactoryForTypeInternal)} arguments:
    {cxtInt.ClassId}
    {cxtInt.InterfaceId}
    0x{(ulong)cxtInt.AssemblyPathBuffer:x}
    0x{(ulong)cxtInt.AssemblyNameBuffer:x}
    0x{(ulong)cxtInt.TypeNameBuffer:x}
    0x{cxtInt.ClassFactoryDest.ToInt64():x}");
            }

            try
            {
                var cxt = new ComActivationContext()
                {
                    ClassId      = cxtInt.ClassId,
                    InterfaceId  = cxtInt.InterfaceId,
                    AssemblyPath = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyPathBuffer)),
                    AssemblyName = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyNameBuffer)),
                    TypeName     = Marshal.PtrToStringUni(new IntPtr(cxtInt.TypeNameBuffer))
                };

                object cf             = GetClassFactoryForType(cxt);
                IntPtr nativeIUnknown = Marshal.GetIUnknownForObject(cf);
                Marshal.WriteIntPtr(cxtInt.ClassFactoryDest, nativeIUnknown);
            }
            catch (Exception e)
            {
                return(e.HResult);
            }

            return(0);
        }