Is the MVID value computed in un-GACd assemblies?  That is, there's no need to have 
the hashed value unless the assembly is going into the GAC -- is there?  (And 
certainly if the assembly was built with /delaysign it won't have the MVID, will it?)

The (unmanaged API) docn for GetHashFromFile (the API I think you were looking at) 
says it "generates a hash over the contents" rather than "retrieves the stored MVID".  
Perhaps it's easier to call than one of the managed or unmanaged HashAlgorithm's, but 
perhaps not.

At 09:41 AM 9/16/2003 -0500, Brian Patterson wrote
>Take a look at the article "Avoiding DLL Hell" by Matt Peitrek.  It
>contains a sample application that uses the unmanaged metadata api's to
>retrieve the MVID.
>
>http://msdn.microsoft.com/msdnmag/issues/1000/metadata/default.aspx
>
>The downloadable code contains 2 projects, you'll need to look at the
>"meta" project in the Meta.cpp file.  He calls GetScopeProps to retrieve
>the information you are looking for.  You can find details of this
>method in the "Metadata Unmanaged API.doc" file that comes with the .NET
>Framework SDK. This document, using version 1.1 of the framework, would
>typically be found:
>
>\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developer
>Guide\docs\
>
>The code Matt wrote is currently in C++ and looks very useful so I may
>port it over to C# when I get home tonight.  If interested, I can send
>the code on to you.
>
>
>Brian Patterson
>
>
>-----Original Message-----
>From: Luca Minudel [mailto:[EMAIL PROTECTED]
>Sent: Monday, September 15, 2003 4:28 PM
>To: [EMAIL PROTECTED]
>Subject: [ADVANCED-DOTNET] How to read MVID and assembly hash?
>
>I like to get a unique identifier of a compiled assembly, this identity
>will
>be attached to results of tests logged in a file.
>The assembly source code is available thus it can be changed and/or
>recompiled by someone else.
>Because one of the assemblies does not have a strong name I cannot rely
>only
>on it.
>
>How can I programmatically read the module version identifier (MVID) of
>an
>assembly module (the unique identifier given to the module at every
>compilation)?
>
>How can I programmatically calculate the hash value of an Assembly (the
>assembly hash that CLR uses to make sure the assembly hasn't been
>altered)?
>
>TIA (luKa)


J. Merrill / Analytical Software Corp

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to