In C# or VB.NET, I would like to know which would be the best approach to determine the PEFileKind of a assembly loaded through Reflection. In other words, determine whether an assembly is a WinExe, Console application, or a Dynamic link library.
I found this solution (the other proposed solutions in that question are not effective), but If I'm not wrong I think it implies to assume that the file loaded is a .NET assembly.
I also found this other solution but reading the comments it seem not effective in some circumstances.
For those reasons, I wonder if exists a truly safe, managed way, through Reflection, to determine the PE file kind of a loaded assembly. For sure the System.Reflection.Emit.PEFileKind enumeration would not exists only for decorative purposes, if that enum exists, probably there is a member/function inside the Reflection namespaces (that I missed) that can return the PEFileKind.
Aucun commentaire:
Enregistrer un commentaire