473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

getting the GUID from of a loaded assembly

Hi: How do I get the GUID string out of an assembly? (I have it loaded and
referenced from an Assembly obect).
-Ron
Dec 26 '06 #1
4 5172
This is an attribute in the Assembly Manifest. You get to it by getting an
instance of the System.Reflection.Assembly class, using:

System.Reflection.Assembly assembly = Assembly.GetExecutingAssembly();

Then you get an Attribute from the assembly using the
Assembly.GetCustomAttributes method:

((System.Runtime.InteropServices.GuidAttribute)ass embly.GetCustomAttributes(
typeof(System.Runtime.InteropServices.GuidAttribut e),false)[0]).Value

Note that you can use this method to get any of the various attributes in
the Assembly, as long as you know the type of the attribute, and what member
of the class you want to get at.

--
HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

A pea rants as candy be sieving.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:ul*************@TK2MSFTNGP02.phx.gbl...
Hi: How do I get the GUID string out of an assembly? (I have it loaded and
referenced from an Assembly obect).
-Ron

Dec 26 '06 #2
[assembly: Guid("6a6bf2ba-b251-492d-83c1-def446287453")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Using this method I am able to read "Guid", "AssemblyFileVersion", but NOT
"AssemblyVersion". Any ideas why that is? is it not going into the compiled
file?

I'm getting "index out of array" indicating this has not been found:

this.version =
((AssemblyVersionAttribute)this.myAssembly.GetCust omAttributes(typeof(AssemblyVersionAttribute),
false)[0]).Version;

-Ron

"Kevin Spencer" <sp**@uce.govwrote in message
news:eb*************@TK2MSFTNGP03.phx.gbl...
This is an attribute in the Assembly Manifest. You get to it by getting an
instance of the System.Reflection.Assembly class, using:

System.Reflection.Assembly assembly = Assembly.GetExecutingAssembly();

Then you get an Attribute from the assembly using the
Assembly.GetCustomAttributes method:

((System.Runtime.InteropServices.GuidAttribute)ass embly.GetCustomAttributes(
typeof(System.Runtime.InteropServices.GuidAttribut e),false)[0]).Value

Note that you can use this method to get any of the various attributes in
the Assembly, as long as you know the type of the attribute, and what
member of the class you want to get at.

--
HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

A pea rants as candy be sieving.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:ul*************@TK2MSFTNGP02.phx.gbl...
>Hi: How do I get the GUID string out of an assembly? (I have it loaded
and referenced from an Assembly obect).
-Ron


Dec 26 '06 #3
Ron,
>Using this method I am able to read "Guid", "AssemblyFileVersion", but NOT
"AssemblyVersion". Any ideas why that is? is it not going into the compiled
file?
The AssemblyVersion gets special treatment as it becomes part of the
full assembly name. You can retrieve it with
myAssembly.GetName().Version.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 26 '06 #4
Use the GetName() method of the Assembly class to get this:

string name = assembly.GetName().Name;
string version = assembly.GetName().Version.ToString(4);

--
HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

A pea rants as candy be sieving.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:uI**************@TK2MSFTNGP03.phx.gbl...
[assembly: Guid("6a6bf2ba-b251-492d-83c1-def446287453")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Using this method I am able to read "Guid", "AssemblyFileVersion", but NOT
"AssemblyVersion". Any ideas why that is? is it not going into the
compiled file?

I'm getting "index out of array" indicating this has not been found:

this.version =
((AssemblyVersionAttribute)this.myAssembly.GetCust omAttributes(typeof(AssemblyVersionAttribute),
false)[0]).Version;

-Ron

"Kevin Spencer" <sp**@uce.govwrote in message
news:eb*************@TK2MSFTNGP03.phx.gbl...
>This is an attribute in the Assembly Manifest. You get to it by getting
an instance of the System.Reflection.Assembly class, using:

System.Reflection.Assembly assembly = Assembly.GetExecutingAssembly();

Then you get an Attribute from the assembly using the
Assembly.GetCustomAttributes method:

((System.Runtime.InteropServices.GuidAttribute)as sembly.GetCustomAttributes(
typeof(System.Runtime.InteropServices.GuidAttribu te),false)[0]).Value

Note that you can use this method to get any of the various attributes in
the Assembly, as long as you know the type of the attribute, and what
member of the class you want to get at.

--
HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

A pea rants as candy be sieving.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:ul*************@TK2MSFTNGP02.phx.gbl...
>>Hi: How do I get the GUID string out of an assembly? (I have it loaded
and referenced from an Assembly obect).
-Ron



Dec 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: asdf | last post by:
Hello, I was enjoying working in VS for half a year without any problems and now I cannot debug anymore. Without any really reason my Studio tells me that the page that I want to debug has - No...
11
by: Vinod I | last post by:
Hi Team, I am having a string as "System.Data.SqlDbType.Int". Now I want to convert this string type to actual type to use with my Command object Parameter Creation. How I will convert this...
14
by: Nak | last post by:
Hi there, Does anyone know how I would get the value of the assembly GUID in code from within the same application? Thanks in advance. Nick. --...
2
by: Brian Henry | last post by:
Is there anyway to retrieve the GUID code of an assembly for use in the application as a unique identifier? thanks!
9
by: Mis Dep. | last post by:
Dear all What is Create GUID on menu Tools in vb.net and how can i use it for something . as exsample Brg, TingN@ng
1
by: Brian Henry | last post by:
I need to mark assemblies with a unique id (GUID in this case) and retrieve it when the assembly is loaded into my application (a plug-in loader)... the plug-in assembly all have a class in it...
3
by: Jozef | last post by:
Hello, I apologize for such a newbie question, but I'd like to know if there's any way to reference the assembly GUID? Thanks!
2
by: Rob R. Ainscough | last post by:
I tried the following and it does provide a GUID, but not the GUID listed in the My Project ... Assembly Info button. Dim myAss As myAss = .GetEntryAssembly Dim myAssGUID As System.Guid =...
2
by: PJ6 | last post by:
In VS.Net 2K3, a GUID use to be automatically included in the project's assemblyinfo.vb file: 'The following GUID is for the ID of the typelib if this project is exposed to COM <Assembly:...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.