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 977153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:51:35+00:00 2026-05-16T03:51:35+00:00

In my application I need to compute a hash of a given .NET assembly

  • 0

In my application I need to compute a hash of a given .NET assembly and of a given type.
Assemblies and types to hash are loaded dynamically in this scenario.

Object’s built-in method GetHashCode returns different value each time an application is started.

How to compute a deterministic hash function of an assembly or a type?

Any assistance would be greatly appreciated.

  • 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-16T03:51:36+00:00Added an answer on May 16, 2026 at 3:51 am

    That depends on what kind of equality you’re looking for, really:

    • If you had another copy of the assembly at a different location, should that change the hash?
    • If the same code was rebuilt, should that change the hash?
    • If the code changed and then was rebuilt, should that change the hash?

    You may find that just hashing the full name of the assembly (or type) is enough… but we’d need to know more about your requirements to say for sure.

    EDIT: To reply to your comment (originally in a comment, but then it was getting too long):

    Okay, that’s somewhat tricky… an assembly file contains some things which change on each build (possibly a build date, possibly a random GUID; it’s a while since I’ve investigated). You’ll want to throw that data away.

    If you’re only interested in signatures for the assembly too, you could iterate over all the public types (in lexicographic order), then get the hash of those types and combine them. For each hash, you would get all public members (possibly protected ones too?) and hash the signatures – e.g. by combining the hash of the full names of the return type, member name, and parameters. For each parameter you’d want to include the type, possibly the name, and the ref/out status of it. As you can see, it gets quite complicated 🙂

    To combine multiple hashes (as this is clearly going to involve somewhere 🙂 I tend to use something like this:

    int hash = 17;
    hash = hash * 31 + FirstHash();
    hash = hash * 31 + SecondHash();
    hash = hash * 31 + ThirdHash();
    // etc
    return hash;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to rename my computer via .net application. I have tried this code:
I have this application that need to do some things in protected paths (like
Background: I have an iterative hash algorithm I need to compute from a Python
I need to restrict users in my application to login from a one computer
In the java web application need to select the file from server and print
Hi every body i am new in iPhone application development. In my application need
I have two application that need to talk to each other. App1 needs to
In my C# application I need to create a .resx file of strings customized
I have an application I need to analyze. I have the source code here.
For my web application I need to close the child window whenever the parent

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.