ExcelDna.Integration.DnaLibrary.GetAssemblies C# (CSharp) Method

GetAssemblies() private method

private GetAssemblies ( string pathResolveRoot ) : List
pathResolveRoot string
return List
        internal List<ExportedAssembly> GetAssemblies(string pathResolveRoot)
        {
            List<ExportedAssembly> assemblies = new List<ExportedAssembly>();
            try
            {
                if (ExternalLibraries != null)
                {
                    foreach (ExternalLibrary lib in ExternalLibraries)
                    {
                        assemblies.AddRange(lib.GetAssemblies(pathResolveRoot, this));
                    }
                }
                foreach (Project proj in GetProjects())
                {
                    assemblies.AddRange(proj.GetAssemblies(pathResolveRoot, this));
                }
            }
            catch (Exception e)
            {
                Logging.LogDisplay.WriteLine("Error while loading assemblies. Exception: " + e.Message);
            }
            return assemblies;
        }

Usage Example

Example #1
0
        public List <Assembly> GetAssemblies()
        {
            try
            {
                string realPath = Path;
                if (!File.Exists(realPath))
                {
                    string xllName        = DnaLibrary.XllPath;
                    string localDirectory = System.IO.Path.GetDirectoryName(xllName);
                    if (System.IO.Path.IsPathRooted(realPath))
                    {
                        // Rooted path -- try locally
                        string fileName = System.IO.Path.GetFileName(realPath);
                        realPath = System.IO.Path.Combine(localDirectory, fileName);
                    }
                    else
                    {
                        // Try a path relative to local directory
                        realPath = System.IO.Path.Combine(localDirectory, realPath);
                    }
                    // Check again
                    if (!File.Exists(realPath))
                    {
                        // Give up.
                        Debug.Print("Could not find file " + Path);
                        return(new List <Assembly>());
                    }
                }
                if (System.IO.Path.GetExtension(realPath).ToLower() == ".dna")
                {
                    // Load as a DnaLibrary
                    DnaLibrary lib = DnaLibrary.LoadFrom(realPath);
                    if (lib == null)
                    {
                        // Problems during load.
                        return(new List <Assembly>());
                    }

                    return(lib.GetAssemblies());
                }
                else
                {
                    // Load as a regular assembly
                    List <Assembly> list = new List <Assembly>();
                    list.Add(Assembly.LoadFrom(realPath));
                    return(list);
                }
            }
            catch (Exception e)
            {
                // Assembly could not be loaded.
                Debug.Print("Assembly load exception for file: " + Path + "\n" + e.ToString());
                return(new List <Assembly>());
            }
        }
All Usage Examples Of ExcelDna.Integration.DnaLibrary::GetAssemblies