Click here to Skip to main content
12,502,009 members (46,520 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.4K views
285 downloads
5 bookmarked
Posted

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

, 14 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
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):

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.)

Reference Link

License

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

Share

About the Author

No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionPost updated Pin
Malay Kumar Pandey19-Apr-14 3:23
memberMalay Kumar Pandey19-Apr-14 3:23 
GeneralWhat about using Corflags.exe? Pin
Mukesh 979136015-Apr-14 18:58
memberMukesh 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
memberMalay 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
memberMember 1068509015-Apr-14 5:34 
GeneralMy vote of 1 Pin
Daniele Rota Nodari14-Apr-14 11:21
memberDaniele Rota Nodari14-Apr-14 11:21 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 14 Apr 2014
Article Copyright 2014 by Malay Kumar Pandey
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid