public bool MoveNext() { if (this.isComplete) { return(false); } IInstallReferenceItem ppRefItem; int installReferenceItem = this.refEnum.GetNextInstallReferenceItem(out ppRefItem, 0, IntPtr.Zero); if (installReferenceItem == -2147024637) { this.isComplete = true; return(false); } else { if (installReferenceItem < 0) { Marshal.ThrowExceptionForHR(installReferenceItem); } InstallReference installRef = new InstallReference(Guid.Empty, string.Empty, string.Empty); IntPtr pRefData; int reference = ppRefItem.GetReference(out pRefData, 0, IntPtr.Zero); if (reference < 0) { Marshal.ThrowExceptionForHR(reference); } Marshal.PtrToStructure(pRefData, (object)installRef); this.currentReference = new AssemblyReference(this.assemblyName, installRef); return(true); } }
private void InstallAssembly(string assemblyPath, InstallReference reference, bool force) { if (reference != null && !InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme)) { throw new ArgumentException("Invalid reference guid.", "reference"); } AssemblyCommitFlags assemblyCommitFlags = force ? AssemblyCommitFlags.Force : AssemblyCommitFlags.Default; IAssemblyCache ppAsmCache; int assemblyCache = NativeMethods.CreateAssemblyCache(out ppAsmCache, 0); Marshal.ThrowExceptionForHR(assemblyCache); if (assemblyCache < 0) { return; } Marshal.ThrowExceptionForHR(ppAsmCache.InstallAssembly((int)assemblyCommitFlags, assemblyPath, reference)); }
private void InstallAssembly(string assemblyPath, InstallReference reference, bool force) { if (reference != null && !InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme)) throw new ArgumentException("Invalid reference guid.", "reference"); AssemblyCommitFlags assemblyCommitFlags = force ? AssemblyCommitFlags.Force : AssemblyCommitFlags.Default; IAssemblyCache ppAsmCache; int assemblyCache = NativeMethods.CreateAssemblyCache(out ppAsmCache, 0); Marshal.ThrowExceptionForHR(assemblyCache); if (assemblyCache < 0) return; Marshal.ThrowExceptionForHR(ppAsmCache.InstallAssembly((int)assemblyCommitFlags, assemblyPath, reference)); }
internal AssemblyCacheUninstallDisposition UninstallAssembly(string assemblyName, InstallReference reference) { AssemblyCacheUninstallDisposition disposition = AssemblyCacheUninstallDisposition.Uninstalled; if (reference != null && !InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme)) throw new ArgumentException("Invalid reference guid.", "reference"); IAssemblyCache ppAsmCache; int errorCode = NativeMethods.CreateAssemblyCache(out ppAsmCache, 0); if (errorCode >= 0) errorCode = ppAsmCache.UninstallAssembly(0, assemblyName, reference, out disposition); if (errorCode < 0) Marshal.ThrowExceptionForHR(errorCode); if (disposition != AssemblyCacheUninstallDisposition.Uninstalled) Trace.TraceWarning(string.Format("Could not uninstall assembly {0}: {1}", (object)assemblyName, (object)((object)disposition).ToString())); return disposition; }
internal AssemblyCacheUninstallDisposition UninstallAssembly(string assemblyName, InstallReference reference) { AssemblyCacheUninstallDisposition disposition = AssemblyCacheUninstallDisposition.Uninstalled; if (reference != null && !InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme)) { throw new ArgumentException("Invalid reference guid.", "reference"); } IAssemblyCache ppAsmCache; int errorCode = NativeMethods.CreateAssemblyCache(out ppAsmCache, 0); if (errorCode >= 0) { errorCode = ppAsmCache.UninstallAssembly(0, assemblyName, reference, out disposition); } if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } if (disposition != AssemblyCacheUninstallDisposition.Uninstalled) { Trace.TraceWarning(string.Format("Could not uninstall assembly {0}: {1}", (object)assemblyName, (object)((object)disposition).ToString())); } return(disposition); }