private void PrintAssembly(AssemblyInformation asm, int level, int[] widths)
        {
            if (asm.Location.StartsWith(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()))
            {
                return;
            }

            string name = "".PadRight(level) + asm.Name;

            if (level > 0)
            {
                name = " ".PadRight(level * "|  ".Length - 2, "|  ") + "\\-" + asm.Name;
            }

            string[] values =
            {
                name,
                asm.VersionAsm,
                asm.VersionFile,
                asm.VersionProduct,
                asm.Arch,
                asm.StronglySigned ? "Signed" : string.Empty,
                asm.DotNetAssembly ? (asm.AllResolved ? "Yes" : "No") : string.IsNullOrEmpty(asm.Location) ? string.Empty : "(N/A)",
                AsmCollection.Values.Where(i => i.Name == asm.Name).Count() > 1 ? "Dupe Asm" : string.IsNullOrEmpty(asm.Location) ? "Not Found" : asm.ResolvedNote,
            };

            PrintRow(values, widths);

            foreach (var refasm in asm.ChildAssemblies)
            {
                PrintAssembly(refasm, level + 1, widths);
            }
        }
        public void GatherInformation(string file)
        {
            if (!File.Exists(file))
            {
                Console.WriteLine("File does not exist: " + file);
                return;
            }

            var info = new AssemblyInformation();

            info.Location       = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar;
            info.File           = Path.GetFileName(file);
            info.VersionProduct = FileVersionInfo.GetVersionInfo(file).ProductVersion ?? string.Empty;
            info.VersionFile    = FileVersionInfo.GetVersionInfo(file).FileVersion ?? string.Empty;

            try
            {
                info.DotNetAssembly = true;
                info.VersionAsm     = AssemblyName.GetAssemblyName(file).Version.ToString();
                info.Name           = AssemblyName.GetAssemblyName(file).Name;
                info.StronglySigned = AssemblyName.GetAssemblyName(file).GetPublicKeyToken().Length != 0;
                info.Arch           = AssemblyName.GetAssemblyName(file).ProcessorArchitecture.ToString();

                var asm = Assembly.LoadFrom(file);
                info.ReferencedAssembliesRaw = asm.GetReferencedAssemblies();

                if (!AsmCollection.Keys.Contains(AssemblyName.GetAssemblyName(file).FullName))
                {
                    AsmCollection.Add(AssemblyName.GetAssemblyName(file).FullName, info);
                }
            }
            catch (FileLoadException)
            {
                info.VersionAsm     = AssemblyName.GetAssemblyName(file).Version.ToString();
                info.Name           = AssemblyName.GetAssemblyName(file).Name;
                info.StronglySigned = AssemblyName.GetAssemblyName(file).GetPublicKeyToken().Length != 0;
                info.Arch           = AssemblyName.GetAssemblyName(file).ProcessorArchitecture.ToString();
                info.ResolvedNote   = "Unable to load";

                if (!AsmCollection.Keys.Contains(AssemblyName.GetAssemblyName(file).FullName))
                {
                    AsmCollection.Add(AssemblyName.GetAssemblyName(file).FullName, info);
                }
            }
            catch (BadImageFormatException)
            {
                info.DotNetAssembly = false;
                info.Name           = Path.GetFileName(file);
                info.VersionAsm     = string.Empty;

                if (!AsmCollection.Keys.Contains(file))
                {
                    AsmCollection.Add(file, info);
                }
            }
            catch (Exception)
            { }
        }
        public void GatherInformation(string file)
        {
            if (!File.Exists(file))
            {
                Console.WriteLine("File does not exist: " + file);
                return;
            }

            var info = new AssemblyInformation();
            info.Location = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar;
            info.File = Path.GetFileName(file);
            info.VersionProduct = FileVersionInfo.GetVersionInfo(file).ProductVersion ?? string.Empty;
            info.VersionFile = FileVersionInfo.GetVersionInfo(file).FileVersion ?? string.Empty;

            try
            {
                info.DotNetAssembly = true;
                info.VersionAsm = AssemblyName.GetAssemblyName(file).Version.ToString();
                info.Name = AssemblyName.GetAssemblyName(file).Name;
                info.StronglySigned = AssemblyName.GetAssemblyName(file).GetPublicKeyToken().Length != 0;
                info.Arch = AssemblyName.GetAssemblyName(file).ProcessorArchitecture.ToString();

                var asm = Assembly.LoadFrom(file);
                info.ReferencedAssembliesRaw = asm.GetReferencedAssemblies();

                if (!AsmCollection.Keys.Contains(AssemblyName.GetAssemblyName(file).FullName))
                    AsmCollection.Add(AssemblyName.GetAssemblyName(file).FullName, info);
            }
            catch (FileLoadException)
            {
                info.VersionAsm = AssemblyName.GetAssemblyName(file).Version.ToString();
                info.Name = AssemblyName.GetAssemblyName(file).Name;
                info.StronglySigned = AssemblyName.GetAssemblyName(file).GetPublicKeyToken().Length != 0;
                info.Arch = AssemblyName.GetAssemblyName(file).ProcessorArchitecture.ToString();
                info.ResolvedNote = "Unable to load";

                if (!AsmCollection.Keys.Contains(AssemblyName.GetAssemblyName(file).FullName))
                    AsmCollection.Add(AssemblyName.GetAssemblyName(file).FullName, info);
            }
            catch (BadImageFormatException)
            {
                info.DotNetAssembly = false;
                info.Name = Path.GetFileName(file);
                info.VersionAsm = string.Empty;

                if (!AsmCollection.Keys.Contains(file))
                    AsmCollection.Add(file, info);
            }
            catch (Exception)
            { }
        }
        private void PrintAssembly(AssemblyInformation asm, int level, int[] widths)
        {
            if (asm.Location.StartsWith(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()))
                return;

            string name = "".PadRight(level) + asm.Name;
            if (level > 0)
            {
                name = " ".PadRight(level*"|  ".Length-2, "|  ") + "\\-" + asm.Name;
            }

            string[] values = {
                name,
                asm.VersionAsm,
                asm.VersionFile,
                asm.VersionProduct,
                asm.Arch,
                asm.StronglySigned ? "Signed" : string.Empty,
                asm.DotNetAssembly ? (asm.AllResolved ? "Yes" : "No") : string.IsNullOrEmpty(asm.Location) ? string.Empty : "(N/A)",
                AsmCollection.Values.Where(i => i.Name == asm.Name).Count() > 1 ? "Dupe Asm" : string.IsNullOrEmpty(asm.Location) ? "Not Found" : asm.ResolvedNote,
            };

            PrintRow(values, widths);

            foreach (var refasm in asm.ChildAssemblies)
                PrintAssembly(refasm, level + 1, widths);
        }