/// <summary> /// Queries info about the specified assembly. /// </summary> /// <param name="assemblyName">Name of the assembly</param> /// <returns></returns> public static string QueryAssemblyInfo(string assemblyName) { var assembyInfo = new AssemblyInfo { cchBuf = 512 }; assembyInfo.currentAssemblyPath = new String(' ', assembyInfo.cchBuf); IAssemblyCache assemblyCache; // If assemblyName is not fully qualified, a random matching may be var hr = GacApi.CreateAssemblyCache(out assemblyCache, 0); if (hr == IntPtr.Zero) { hr = assemblyCache.QueryAssemblyInfo(1, assemblyName, ref assembyInfo); if (hr != IntPtr.Zero) { Marshal.ThrowExceptionForHR(hr.ToInt32()); } } else { Marshal.ThrowExceptionForHR(hr.ToInt32()); } return(assembyInfo.currentAssemblyPath); }
private IEnumerable <string> GetReferencesIdentity() { var defaultReferences = ProjectHelper.GetDefaultReferences(FullPath); return(project .GetItems(ReferenceItemType) .Where(item => { var identity = item.GetMetadataValue("Identity"); if (defaultReferences.Any(reference => string.Compare(reference, identity, true) == 0)) { return false; } var copyLocal = item.GetMetadataValue("Private"); if (string.IsNullOrEmpty(copyLocal)) { return GacApi.AssemblyExist(identity); } else { return string.Compare(copyLocal, "false", true) == 0; } }) .Select(item => item.GetMetadataValue("Identity"))); }