Click here to Skip to main content
15,867,568 members
Articles / Programming Languages / C#
Tip/Trick

How to Determine if a .NET Assembly was Built for x86 or x64?

Rate me:
Please Sign up or sign in to vote.
3.00/5 (5 votes)
14 Apr 2014CPOL 25.3K   466   5   8
An application to read assembly name information c#.net reflection

Introduction

This post demonstrates how to read .NET assembly name metadata.

Background

Originally, I require to detect whether the target platform for any .NET assembly is built? After digging, I end up with creating a small Winform application which can display some Assembly name attributes.

Using the Code

This code can be utilized by firstly calling the GetAssemblyName method in AssemblyName class in System.Reflection namespace (as shown below) and then fetching the different attributes of the assembly to be analyzed.

Read assembly metadata using reflection (System.Reflection):

C#
var assemblyInfo = AssemblyName.GetAssemblyName(textBoxAssemblyFilePath.Text); 
var assemblyName = assemblyInfo.Name 
var assemblyVersion = assemblyInfo.Version 
//similarly to find process architecture  
var assemblyArchitecture = assemblyName.ProcessorArchitecture; 

Using the Sample Application

To find the process architecture of the .NET Assembly, just download the sample application with this post and execute.

Select the assembly to analyse and click on 'Read Assembly Metadata'.

The description text box will show the metadata for which I have programmed. If required, you can do some more research to read other metadata associated with the assembly like - Culture Info, Signing information, private and public key information, etc. (See the screenshot below.)

Image 1

Reference Link

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionPost updated Pin
Malay Kumar Pandey19-Apr-14 3:23
Malay Kumar Pandey19-Apr-14 3:23 
GeneralWhat about using Corflags.exe? Pin
Mukesh 979136015-Apr-14 18:58
Mukesh 979136015-Apr-14 18:58 
GeneralRe: What about using Corflags.exe? Pin
Andreas Gieriet19-Apr-14 21:40
professionalAndreas Gieriet19-Apr-14 21:40 
GeneralRe: What about using Corflags.exe? Pin
Malay Kumar Pandey20-Apr-14 1:54
Malay Kumar Pandey20-Apr-14 1:54 
GeneralRe: What about using Corflags.exe? Pin
Andreas Gieriet20-Apr-14 2:15
professionalAndreas Gieriet20-Apr-14 2:15 
GeneralMy vote of 1 Pin
Jason Curl15-Apr-14 10:11
professionalJason Curl15-Apr-14 10:11 
GeneralMy vote of 1 Pin
Member 1068509015-Apr-14 5:34
Member 1068509015-Apr-14 5:34 
GeneralMy vote of 1 Pin
Daniele Rota Nodari14-Apr-14 11:21
Daniele Rota Nodari14-Apr-14 11:21 
You didn't explain how to obtain that information, more this seems more a tip than an article.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.