// See comments in UninstallAssembly public static String QueryAssemblyInfo(String assemblyName, GACVersion gacVersion = GACVersion.Net40) { if (assemblyName == null) { throw new ArgumentException("Invalid name", "assemblyName"); } var aInfo = new AssemblyInfo(); aInfo.cchBuf = 1024; // Get a string with the desired length aInfo.currentAssemblyPath = new String('\0', aInfo.cchBuf); IAssemblyCache ac = null; int hr = 0; switch (gacVersion) { case GACVersion.Net40: hr = Utils.CreateAssemblyCache40(out ac, 0); break; case GACVersion.Net20: hr = Utils.CreateAssemblyCache20(out ac, 0); break; } if (hr >= 0) { hr = ac.QueryAssemblyInfo(0, assemblyName, ref aInfo); } if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } return aInfo.currentAssemblyPath; }
// See comments in UninstallAssembly public static String QueryAssemblyInfo(String assemblyName) { if (assemblyName == null) { throw new ArgumentException("Invalid name", "assemblyName"); } AssemblyInfo aInfo = new AssemblyInfo(); aInfo.cchBuf = 1024; // Get a string with the desired length aInfo.currentAssemblyPath = new String('\0', aInfo.cchBuf) ; IAssemblyCache ac = null; int hr = Utils.CreateAssemblyCache(out ac, 0); if (hr >= 0) { hr = ac.QueryAssemblyInfo(0, assemblyName, ref aInfo); } if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } return aInfo.currentAssemblyPath; }