public static IAssemblyCache GetAssemblyCacheInterface(string CLRVersionString, bool FetchRuntimeHost, out CCorRuntimeHost RuntimeHost)
        {
            IClrMetaHostPolicy clrMetaHostPolicy = null;

            RuntimeHost = null;
            GetClrMetaHostPolicy(ref _metaHostPolicyClsIdGuid, ref _metaHostPolicyGuid, out clrMetaHostPolicy);
            if (clrMetaHostPolicy == null)
            {
                return(null);
            }
            StringBuilder version = new StringBuilder("v", "v65535.65535.65535".Length);

            version.Append(CLRVersionString);
            int             capacity           = version.Capacity;
            int             imageVersionLength = 0;
            int             pdwConfigFlags     = 0;
            IClrRuntimeInfo runtimeInfo        = (IClrRuntimeInfo)clrMetaHostPolicy.GetRequestedRuntime(MetaHostPolicyFlags.MetaHostPolicyApplyUpgradePolicy, null, null, version, ref capacity, null, ref imageVersionLength, out pdwConfigFlags, _clrRuntimeInfoGuid);

            if (runtimeInfo == null)
            {
                return(null);
            }
            CoInitializeEEDelegate delegateForFunctionPointer = (CoInitializeEEDelegate)Marshal.GetDelegateForFunctionPointer(runtimeInfo.GetProcAddress("CoInitializeEE"), typeof(CoInitializeEEDelegate));

            Marshal.ThrowExceptionForHR(delegateForFunctionPointer(0));
            if (FetchRuntimeHost)
            {
                RuntimeHost = new CCorRuntimeHost(runtimeInfo);
            }
            CreateAssemblyCacheDelegate delegate3 = (CreateAssemblyCacheDelegate)Marshal.GetDelegateForFunctionPointer(runtimeInfo.GetProcAddress("CreateAssemblyCache"), typeof(CreateAssemblyCacheDelegate));
            IAssemblyCache ppAsmCache             = null;

            Marshal.ThrowExceptionForHR(delegate3(out ppAsmCache, 0));
            return(ppAsmCache);
        }
 private static extern void GetClrMetaHostPolicy(ref Guid clsid, ref Guid iid, [MarshalAs(UnmanagedType.Interface)] out IClrMetaHostPolicy ClrMetaHostPolicy);