C#C
C#3y ago
__cdeclan

❔ Help with Assemblies and the TypeRef table

I am trying to load a .NET DLL as an assembly and read the TypeRef table. End goal is to get all the TypeNames and their corresponding NameSpaces.
The image shows all the results I should get, but I am only getting one result "Program". Code provided

   public List<TypesClass> parseBinary()
    {
        Console.WriteLine("Calculating TypeRef hash for: " + binaryName);

        Assembly asm = Assembly.LoadFile(binaryName);
        List<Type> typesList = asm.GetExportedTypes().ToList();
        List<TypesClass> allTypes = new List<TypesClass>();

        foreach (Type t in typesList)
        {
            TypesClass newType = new TypesClass();
            newType.TypeName = t.Name;

            if (t.Namespace == null)
            {
                newType.TypeNameSpace = "";
            }
            else
            {
                newType.TypeNameSpace = t.Namespace;
            }
            allTypes.Add(newType);
        }

        return allTypes;
    }
image.png
Was this page helpful?