Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

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

0.00/5 (No votes)
14 Apr 2014 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here