2

How can I programmatically tell in C# if an unmanaged lib is x86 or x64?

ThinkingStiff
  • 63,812
  • 29
  • 142
  • 238
Devloper
  • 219
  • 2
  • 4
  • 12

1 Answers1

2

Unless you get a better solution - run Corflags using Process.Start and parse the output.

Or better yet - read the file header from .NET - luckily a this question already been answered: How to find if native dll is compiled as x64 or x86?

Community
  • 1
  • 1
Dror Helper
  • 29,703
  • 15
  • 79
  • 129
  • 2
    So doesn't that make it a duplicate? – Brian Rasmussen Feb 25 '10 at 11:42
  • hi Dror, I Have already gone through the link but it is working for DLL not for libraries. Thanks. – Devloper Feb 25 '10 at 11:46
  • Hi All, I am getting exception on the below line when i am trying to find whether the lib is x86 or x64... UInt32 peHead = br.ReadUInt32(); Is i need to do some chnages for the library files. – Devloper Feb 25 '10 at 12:01