public static IEnumerable <InstallReference> GetInstallReferences(AssemblyName assemblyName)
        {
            ComCheck(FusionApi.CreateAssemblyNameObject(out var fusionAssemblyName, assemblyName.GetFullyQualifiedName(),
                                                        CreateAssemblyNameObjectFlags.ParseDisplayName, IntPtr.Zero));

            ComCheck(FusionApi.CreateInstallReferenceEnum(out var installReferenceEnum, fusionAssemblyName, 0,
                                                          IntPtr.Zero));

            do
            {
                var hResult = installReferenceEnum.GetNextInstallReferenceItem(out var item, 0, IntPtr.Zero);
                if ((uint)hResult == 0x80070103)  // ERROR_NO_MORE_ITEMS
                {
                    yield break;
                }
                ComCheck(hResult);

                ComCheck(item.GetReference(out var refData, 0, IntPtr.Zero));

                var fusionReference = new FusionInstallReference();
                Marshal.PtrToStructure(refData, fusionReference);

                var reference = new InstallReference(InstallReferenceGuid.ToType(fusionReference.GuidScheme),
                                                     fusionReference.Identifier,
                                                     fusionReference.NonCanonicalData);

                yield return(reference);
            } while (true);
        }
Example #2
0
 public FusionInstallReference(InstallReferenceType type, string identifier, string nonCanonicalData)
     : this(InstallReferenceGuid.FromType(type), identifier, nonCanonicalData)
 {
 }