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)


.



CONFIDENTIALITY NOTICE: This communication, including any attachments, is intended 
only for the use of the individual or entity to which it is addressed and contains 
information which may be confidential.  If you are not the intended recipient, any 
distribution or copying of this communication is strictly prohibited.  If you have 
received this communication in error, notify the sender immediately, delete the 
communication and destroy all copies. Thank you for your compliance.

===================================
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