コード例 #1
0
        internal static IClrStrongName GetInstance()
        {
            Guid metaHostClsid = new Guid(unchecked ((int)0x9280188D), 0xE8E, 0x4867, 0xB3, 0xC, 0x7F, 0xA8, 0x38, 0x84, 0xE8, 0xDE);

            Guid metaHostGuid       = new Guid(unchecked ((int)0xD332DB9E), unchecked ((short)0xB9B3), 0x4125, 0x82, 0x07, 0xA1, 0x48, 0x84, 0xF5, 0x32, 0x16);
            Guid clrStrongNameClsid = new Guid(unchecked ((int)0xB79B0ACD), unchecked ((short)0xF5CD), 0x409b, 0xB5, 0xA5, 0xA1, 0x62, 0x44, 0x61, 0x0B, 0x92);
            Guid clrRuntimeInfoGuid = new Guid(unchecked ((int)0xBD39D1D2), unchecked ((short)0xBA2F), 0x486A, 0x89, 0xB0, 0xB4, 0xB0, 0xCB, 0x46, 0x68, 0x91);
            Guid clrStrongNameGuid  = new Guid(unchecked ((int)0x9FD93CCF), 0x3280, 0x4391, 0xB3, 0xA9, 0x96, 0xE1, 0xCD, 0xE7, 0x7C, 0x8D);

            IClrMetaHost    metaHost = (IClrMetaHost)nCreateInterface(metaHostClsid, metaHostGuid);
            IClrRuntimeInfo runtime  = (IClrRuntimeInfo)metaHost.GetRuntime(GetRuntimeVersion(), clrRuntimeInfoGuid);

            return((IClrStrongName)runtime.GetInterface(clrStrongNameClsid, clrStrongNameGuid));
        }
コード例 #2
0
        bool IsCLRVersionInstalled(Version clrVersion)
        {
            object pCLRMetaHost;
            bool   isRuntimeVersionDetermined = false;

            if (SafeNativeMethods.ERROR_SUCCESS == SafeNativeMethods.CLRCreateInstance(CLSID_CLRMetaHost, typeof(IClrMetaHost).GUID, out pCLRMetaHost))
            {
                IClrMetaHost metaHost = (IClrMetaHost)pCLRMetaHost;
                IEnumUnknown enumUnknownPtr;

                enumUnknownPtr = metaHost.EnumerateInstalledRuntimes();

                object[] pUnk = new object[1];
                int      pceltFetched;

                while (SafeNativeMethods.ERROR_SUCCESS == enumUnknownPtr.Next(1, pUnk, out pceltFetched) && !isRuntimeVersionDetermined)
                {
                    int           bufferSize = 256;
                    StringBuilder builder    = new StringBuilder(256);

                    IClrRuntimeInfo runtimeInfo = (IClrRuntimeInfo)pUnk[0];
                    runtimeInfo.GetVersionString(builder, ref bufferSize);
                    Version installedClrVersion;

                    if (TryGetVersionFromString(builder, out installedClrVersion))
                    {
                        if (clrVersion.Major == installedClrVersion.Major && clrVersion.Minor == installedClrVersion.Minor)
                        {
                            isRuntimeVersionDetermined = true;
                        }
                    }
                }
            }

            return(isRuntimeVersionDetermined);
        }
コード例 #3
0
 public static extern void CLRCreateInstance(
     ref Guid clsid,
     ref Guid riid,
     [MarshalAs(UnmanagedType.Interface)] out IClrMetaHost metahostInterface);