Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:47:13+00:00 2026-05-30T14:47:13+00:00

I need to determine programmatically whether an assembly is x86, x64 or AnyCPU? There

  • 0

I need to determine programmatically whether an assembly is x86, x64 or AnyCPU? There is an almost identical question, but the solution that it provides

Assembly assembly = Assembly.LoadFrom(fileName);
PortableExecutableKinds peKind;
ImageFileMachine imageFileMachine;
assembly.ManifestModule.GetPEKind(out peKind, out imageFileMachine);

fails when trying to load a 64-bit assembly from a 32-bit process (and vice versa).

Is there a foolproof way of programmatically finding out the compilation type of an assembly?

EDIT: Based on @BenVoigt suggestion, I created a small command line utility that checks whether the DLL is managed or not and whether its x86/x64/AnyCPU. I hope someone finds it useful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:47:14+00:00Added an answer on May 30, 2026 at 2:47 pm

    This question’s been covered already:

    • How to Tell if a .NET Assembly Was Compiled as x86, x64 or Any CPU
    • How to determine if a .NET assembly was built for x86 or x64?
    • How can I get the processor architecture of an assembly dll?

    But the answers are incomplete, suggesting use of Assembly.LoadFrom. That’s a terrible idea, since it will run code from the assembly, in addition to failing if the bitness doesn’t match your process.

    Instead, you should use Assembly.ReflectionOnlyLoadFrom. This lets you read the metadata without actually loading any code, and therefore there’s no need for the architecture to be correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to this question but for MySQL.... How can I programmatically determine foreign key
I need to programatically determine whether .NET 3.5 is installed. I thought it would
I need to programmatically determine out how many sectors, heads, and cylinders are on
I need to determine which pages of a Word document that a keyword occurs
I need to determine programmatically if the database supports the Geography data type and
I need to programmatically determine the Router NAT type in my program. I did
I need to be able to programmatically determine the doctype of the current page
I need to programmatically determine the name of the users who are administrator on
I'm using IIS 6. I need to determine whether a certain site is running
I need a regex that will determine if a given SQL statement has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.