Beispiel #1
0
        internal static string RetrievePathFromFusionName(string strongName)
        {
            // Extra checks for PInvoke-destined data.
            ErrorUtilities.VerifyThrowArgumentNull(strongName, "assemblyName");

            IAssemblyCache assemblyCache;

            uint hr = NativeMethods.CreateAssemblyCache(out assemblyCache, 0);

            ErrorUtilities.VerifyThrow(hr == NativeMethodsShared.S_OK, "CreateAssemblyCache failed, hr {0}", hr);

            ASSEMBLY_INFO assemblyInfo = new ASSEMBLY_INFO();

            assemblyInfo.cbAssemblyInfo = (uint)Marshal.SizeOf(typeof(ASSEMBLY_INFO));

            assemblyCache.QueryAssemblyInfo(0, strongName, ref assemblyInfo);

            if (assemblyInfo.cbAssemblyInfo == 0)
            {
                return(null);
            }

            assemblyInfo.pszCurrentAssemblyPathBuf = new string(new char[assemblyInfo.cchBuf]);

            assemblyCache.QueryAssemblyInfo(0, strongName, ref assemblyInfo);

            String value = assemblyInfo.pszCurrentAssemblyPathBuf;

            return(value);
        }
Beispiel #2
0
        internal static string RetreivePathFromFusionName(string strongName)
        {
            IAssemblyCache cache;

            Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgumentNull(strongName, "assemblyName");
            uint num = Microsoft.Build.Tasks.NativeMethods.CreateAssemblyCache(out cache, 0);

            Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(num == 0, "CreateAssemblyCache failed, hr {0}", num);
            ASSEMBLY_INFO pAsmInfo = new ASSEMBLY_INFO {
                cbAssemblyInfo = (uint)Marshal.SizeOf(typeof(ASSEMBLY_INFO))
            };

            cache.QueryAssemblyInfo(0, strongName, ref pAsmInfo);
            if (pAsmInfo.cbAssemblyInfo == 0)
            {
                return(null);
            }
            pAsmInfo.pszCurrentAssemblyPathBuf = new string(new char[pAsmInfo.cchBuf]);
            cache.QueryAssemblyInfo(0, strongName, ref pAsmInfo);
            return(pAsmInfo.pszCurrentAssemblyPathBuf);
        }
        internal static string RetrievePathFromFusionName(string strongName)
        {
            // Extra checks for PInvoke-destined data.
            ErrorUtilities.VerifyThrowArgumentNull(strongName, nameof(strongName));

            string value;

            if (NativeMethodsShared.IsWindows)
            {
                uint hr = NativeMethods.CreateAssemblyCache(out IAssemblyCache assemblyCache, 0);

                ErrorUtilities.VerifyThrow(hr == NativeMethodsShared.S_OK, "CreateAssemblyCache failed, hr {0}", hr);

                var assemblyInfo = new ASSEMBLY_INFO {
                    cbAssemblyInfo = (uint)Marshal.SizeOf <ASSEMBLY_INFO>()
                };

                assemblyCache.QueryAssemblyInfo(0, strongName, ref assemblyInfo);

                if (assemblyInfo.cbAssemblyInfo == 0)
                {
                    return(null);
                }

                assemblyInfo.pszCurrentAssemblyPathBuf = new string(new char[assemblyInfo.cchBuf]);

                assemblyCache.QueryAssemblyInfo(0, strongName, ref assemblyInfo);

                value = assemblyInfo.pszCurrentAssemblyPathBuf;
            }
            else
            {
                value = NativeMethods.AssemblyCacheEnum.AssemblyPathFromStrongName(strongName);
            }

            return(value);
        }
        internal static string RetrievePathFromFusionName(string strongName)
        {
            // Extra checks for PInvoke-destined data.
            ErrorUtilities.VerifyThrowArgumentNull(strongName, "assemblyName");

            IAssemblyCache assemblyCache;

            uint hr = NativeMethods.CreateAssemblyCache(out assemblyCache, 0);

            ErrorUtilities.VerifyThrow(hr == NativeMethodsShared.S_OK, "CreateAssemblyCache failed, hr {0}", hr);

            ASSEMBLY_INFO assemblyInfo = new ASSEMBLY_INFO();
            assemblyInfo.cbAssemblyInfo = (uint)Marshal.SizeOf(typeof(ASSEMBLY_INFO));

            assemblyCache.QueryAssemblyInfo(0, strongName, ref assemblyInfo);

            if (assemblyInfo.cbAssemblyInfo == 0) return null;

            assemblyInfo.pszCurrentAssemblyPathBuf = new string(new char[assemblyInfo.cchBuf]);

            assemblyCache.QueryAssemblyInfo(0, strongName, ref assemblyInfo);

            String value = assemblyInfo.pszCurrentAssemblyPathBuf;

            return value;
        }
 internal static string RetreivePathFromFusionName(string strongName)
 {
     IAssemblyCache cache;
     Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgumentNull(strongName, "assemblyName");
     uint num = Microsoft.Build.Tasks.NativeMethods.CreateAssemblyCache(out cache, 0);
     Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(num == 0, "CreateAssemblyCache failed, hr {0}", num);
     ASSEMBLY_INFO pAsmInfo = new ASSEMBLY_INFO {
         cbAssemblyInfo = (uint) Marshal.SizeOf(typeof(ASSEMBLY_INFO))
     };
     cache.QueryAssemblyInfo(0, strongName, ref pAsmInfo);
     if (pAsmInfo.cbAssemblyInfo == 0)
     {
         return null;
     }
     pAsmInfo.pszCurrentAssemblyPathBuf = new string(new char[pAsmInfo.cchBuf]);
     cache.QueryAssemblyInfo(0, strongName, ref pAsmInfo);
     return pAsmInfo.pszCurrentAssemblyPathBuf;
 }