csscript.AssemblyEnum.GetNextAssembly C# (CSharp) Method

GetNextAssembly() public method

public GetNextAssembly ( ) : string
return string
        public string GetNextAssembly()
        {
            string retval = null;
            if (!m_done)
            {
                IAssemblyName asmName = null;
                COM.CheckHR(m_assemblyEnum.GetNextAssembly((IntPtr)0, out asmName, 0));

                if (asmName != null)
                    retval = GetFullName(asmName);

                m_done = (retval == null);
            }
            return retval;
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Resolves namespace into array of global assembly (GAC) locations.
        /// </summary>
        /// <param name="namespaceStr">'namespace' name</param>
        /// <returns>collection of assembly file names where namespace is implemented</returns>
        public static string[] FindGlobalAssembly(String namespaceStr)
        {
            var retval = new List <string>();

            if (Utils.IsMono)
            {
                if (Utils.MonoGAC.Contains(namespaceStr))
                {
                    retval.Add(namespaceStr);
                }
            }

            if (!retval.Any() && Utils.IsWin)
            {
                try
                {
                    AssemblyEnum asmEnum = new csscript.AssemblyEnum(namespaceStr);

                    string highestVersion = "";
                    string asmName        = "";
                    do
                    {
                        asmName = asmEnum.GetNextAssembly();
                        if (string.Compare(asmName, highestVersion) > 0)
                        {
                            highestVersion = asmName;
                        }

                        if (namespaceStr.Contains(", Version=")) //the assembly was specified by its full name
                        {
                            break;                               //stop searching for the higher version
                        }
                    }while (asmName != null);

                    if (highestVersion != "")
                    {
                        string asmLocation = AssemblyCache.QueryAssemblyInfo(highestVersion);
                        retval.Add(asmLocation);
                    }
                }
                catch (Exception)
                {
                    // fuslion.dll cannot be found under Mono even if it is running on Windows
                    //If exception is thrown it is very likely it is because where fusion.dll does not exist/unavailable/broken.
                    //We might be running under the MONO run-time.
                }
            }

            if (retval.Count == 0 && namespaceStr.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
            {
                retval.Add(namespaceStr); //in case of if the namespaceStr is a dll name
            }
            return(retval.ToArray());
        }
All Usage Examples Of csscript.AssemblyEnum::GetNextAssembly