How do I expand (by code) an assembly of flags?
I need to write an application like CorFlags. If I have the path to the assembly file, how can I read it from CorFlags?
I especially need to know if the assembly is Any-CPU or x86 only
I want to avoid loading an assembly using reflection because I have to scan a lot of files.
+2
Saar
source
to share
3 answers
If you don't want to use reflection, you can check
CCI http://ccimetadata.codeplex.com/Wiki/View.aspx?title=API%20overview or
Mono.Cecil http://www.mono-project.com/Cecil
+3
Lex li
source
to share
Check out this link, it describes a similar situation with your request. The accepted answer describes how you can use reflection and Module.GetPEKind . This might help you.
Edit: a little late, but here's an example:
namespace ConsoleApplication1
{
using System.Reflection;
public class Program
{
public static void Main()
{
Assembly a = Assembly.GetExecutingAssembly();
PortableExecutableKinds peKind;
ImageFileMachine machine;
a.ManifestModule.GetPEKind(out peKind, out machine);
}
}
}
+10
Jason evans
source
to share
System.Reflection.Assembly has a whole bunch of things to help you with this.
var asmbly = Assembly.ReflectionOnlyLoad("filename");
var PeFlags = asmbly.ManifestModule.GetPEKind();
//PeFlags is effectively CorFlags.
+4
Spence
source
to share