473,395 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Assembly GUID

Nak
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.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #1
14 14216
Hi Nick,
you can get most Assembly info from the System.Reflection namespace.
You get the current domain from the AppDomain type, then get the list of
assemblies from it. When you find the assembly that you are looking for (the
list contains all the system assemblies as well), check the referenced
assemblies for that one assembly - the referenced assembly is of type
AssemblyName, and you can get a load of info from that. I'm not sure about
the GUID, but it as a PublicKeyToken property, which may be what you are
looking for....

Here's some code to get you started:

Dim ad As AppDomain

Dim ass As System.Reflection.Assembly

Dim add() As System.Reflection.Assembly = ad.CurrentDomain.GetAssemblies()

Dim addRef() As System.Reflection.AssemblyName

Dim addRefItem As System.Reflection.AssemblyName

For Each ass In add

If ass.ToString.Substring(0, 5).ToUpper = "THE APP NAME" Then

addRef = ass.GetReferencedAssemblies

For Each addRefItem In addRef

Next

Next



"Nak" <a@a.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
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.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Nov 20 '05 #2
Nak
Hi Thomas,

Thanks for your help, the GUID that I am after is actually the one that is
exposed to COM, if you take a look in the AssemblyInfo.vb file you will see
the lines,

'The following GUID is for the ID of the typelib if this project is exposed
to COM
<Assembly: Guid(" GUID goes in here ")>

I am after getting this GUID programatically. I thought it might be in the
application object, as is everything else that is in the Assembly file but
it isn't. I want to use it for making toolbar and menu buttons for Internet
Explorer, and for this you need to provide a GUID. I didn't want to just
use a randomly generated GUID just incase it had been used perviously
(though I am not sure of the chances of this happening are). So I thought
if I use my applications GUID this would solve all problems. I'm short of
copying an pasting but I don't like canning things like that.

Thanks for your help though, any ideas on the above?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"Thomas" <no****@nospam.nospam> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi Nick,
you can get most Assembly info from the System.Reflection namespace.
You get the current domain from the AppDomain type, then get the list of
assemblies from it. When you find the assembly that you are looking for (the list contains all the system assemblies as well), check the referenced
assemblies for that one assembly - the referenced assembly is of type
AssemblyName, and you can get a load of info from that. I'm not sure about
the GUID, but it as a PublicKeyToken property, which may be what you are
looking for....

Here's some code to get you started:

Dim ad As AppDomain

Dim ass As System.Reflection.Assembly

Dim add() As System.Reflection.Assembly = ad.CurrentDomain.GetAssemblies()

Dim addRef() As System.Reflection.AssemblyName

Dim addRefItem As System.Reflection.AssemblyName

For Each ass In add

If ass.ToString.Substring(0, 5).ToUpper = "THE APP NAME" Then

addRef = ass.GetReferencedAssemblies

For Each addRefItem In addRef

Next

Next



"Nak" <a@a.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
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.

--

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


Nov 20 '05 #3
Nak
Sorry, Hi again,

I have found that using the following obtains a GUID

System.Reflection.Assembly.GetExecutingAssembly.Ge tType.GUID.ToString

But the GUID returns is not identical to the one in the AssemblyInfo
file, but, this may still be what I am after. Any idea why this GUID is
different? Thanks again.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"Nak" <a@a.com> wrote in message
news:OQ*************@tk2msftngp13.phx.gbl...
Hi Thomas,

Thanks for your help, the GUID that I am after is actually the one that is
exposed to COM, if you take a look in the AssemblyInfo.vb file you will see the lines,

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid(" GUID goes in here ")>

I am after getting this GUID programatically. I thought it might be in the application object, as is everything else that is in the Assembly file but
it isn't. I want to use it for making toolbar and menu buttons for Internet Explorer, and for this you need to provide a GUID. I didn't want to just
use a randomly generated GUID just incase it had been used perviously
(though I am not sure of the chances of this happening are). So I thought
if I use my applications GUID this would solve all problems. I'm short of
copying an pasting but I don't like canning things like that.

Thanks for your help though, any ideas on the above?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ "Thomas" <no****@nospam.nospam> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi Nick,
you can get most Assembly info from the System.Reflection namespace.
You get the current domain from the AppDomain type, then get the list of
assemblies from it. When you find the assembly that you are looking for

(the
list contains all the system assemblies as well), check the referenced
assemblies for that one assembly - the referenced assembly is of type
AssemblyName, and you can get a load of info from that. I'm not sure about
the GUID, but it as a PublicKeyToken property, which may be what you are
looking for....

Here's some code to get you started:

Dim ad As AppDomain

Dim ass As System.Reflection.Assembly

Dim add() As System.Reflection.Assembly = ad.CurrentDomain.GetAssemblies()
Dim addRef() As System.Reflection.AssemblyName

Dim addRefItem As System.Reflection.AssemblyName

For Each ass In add

If ass.ToString.Substring(0, 5).ToUpper = "THE APP NAME" Then

addRef = ass.GetReferencedAssemblies

For Each addRefItem In addRef

Next

Next



"Nak" <a@a.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
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.

--

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\



Nov 20 '05 #4
"Nak" <a@a.com> schrieb
Sorry, Hi again,

I have found that using the following obtains a GUID
System.Reflection.Assembly.GetExecutingAssembly.Ge tType.GUID.ToString
But the GUID returns is not identical to the one in the
AssemblyInfo
file, but, this may still be what I am after. Any idea why this GUID
is different? Thanks again.

Imports System.Reflection
Imports System.Runtime.InteropServices

'...

Dim assy As [Assembly]
Dim Attributes As Object()

assy = [Assembly].GetExecutingAssembly
Attributes = assy.GetCustomAttributes(GetType(GuidAttribute), False)

If Attributes.Length = 0 Then
MsgBox("no guid attribute")
Else
MsgBox(DirectCast(Attributes(0), GuidAttribute).Value)
End If

--
Armin

Nov 20 '05 #5
Nak
>Unfortunately, pervious use of GUIDs is becoming increasingly common.

LOL! You know what I meant haha :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #6
Nak
Thank you very much Armin :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

--
Armin

Nov 20 '05 #7
Nak
As a matter of interest, why the "[]" square braces around the declarations,
what does it do? Thanks in advance.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"Armin Zingler" <az*******@freenet.de> wrote in message
news:Op*************@TK2MSFTNGP09.phx.gbl...
"Nak" <a@a.com> schrieb
Sorry, Hi again,

I have found that using the following obtains a GUID
System.Reflection.Assembly.GetExecutingAssembly.Ge tType.GUID.ToString
But the GUID returns is not identical to the one in the
AssemblyInfo
file, but, this may still be what I am after. Any idea why this GUID
is different? Thanks again.

Imports System.Reflection
Imports System.Runtime.InteropServices

'...

Dim assy As [Assembly]
Dim Attributes As Object()

assy = [Assembly].GetExecutingAssembly
Attributes = assy.GetCustomAttributes(GetType(GuidAttribute), False)

If Attributes.Length = 0 Then
MsgBox("no guid attribute")
Else
MsgBox(DirectCast(Attributes(0), GuidAttribute).Value)
End If

--
Armin

Nov 20 '05 #8
"Nak" <a@a.com> schrieb:
As a matter of interest, why the "[]" square braces around the
declarations, what does it do? Thanks in advance.


http://msdn.microsoft.com/library/en...amesincode.asp

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #9
"Nak" <a@a.com> schrieb
As a matter of interest, why the "[]" square braces around the
declarations, what does it do? Thanks in advance.


Assembly is a VB keyword. To distinguish between the keyword and the data
type, the braces are used.

see also:
<F1>
Visual Studio.NET
Visual Basic and Visual C#
Reference
Visual Basic language
Visual Basic Language Tour
Features
Declared elements
Name of declared elements

Direct link (VS 2003):
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vbcn7/html/vbconElementNames.htm

(see hints in signature)
--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.
- The tree representing the table of contents has been translated from
localized (German) version. Excuse slight deviations.
Nov 20 '05 #10
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> schrieb

http://msdn.microsoft.com/library/en...amesincode.asp

_That's_ the one I was looking for.

;-)
--
Armin

Nov 20 '05 #11
"Armin Zingler" <az*******@freenet.de> schrieb:
http://msdn.microsoft.com/library/en...amesincode.asp
_That's_ the one I was looking for.


It's really hard to find...

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #12
Nak
Thanks loads Armin :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
"Nak" <a@a.com> schrieb
As a matter of interest, why the "[]" square braces around the
declarations, what does it do? Thanks in advance.


Assembly is a VB keyword. To distinguish between the keyword and the data
type, the braces are used.

see also:
<F1>
Visual Studio.NET
Visual Basic and Visual C#
Reference
Visual Basic language
Visual Basic Language Tour
Features
Declared elements
Name of declared elements

Direct link (VS 2003):
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vbcn7/html/vbconElementNames.htm

(see hints in signature)
--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.
- The tree representing the table of contents has been translated from
localized (German) version. Excuse slight deviations.

Nov 20 '05 #13
Thanks for Armin's codes,

Nick, the GUID you got in from these codes is actually the GUID of the
System.Reflection.Assembly type, not the GUID for you assembly. So it's
different from the GUID in the AssemblyInfo.vb file.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #14
Nak
> Nick, the GUID you got in from these codes is actually the GUID of the
System.Reflection.Assembly type, not the GUID for you assembly. So it's
different from the GUID in the AssemblyInfo.vb file.


Aah, thanks for the info. I've got a nice little routine that gets the
applications GUID now, just what I wanted. :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #15

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

Similar topics

0
by: James Thurley | last post by:
I'm trying to dynamically compile assemblies and cache them to disk, which seems to work fine. When the data I'm compiling from changes, I want to re-generate the assembly and use the new version....
5
by: Tamir Khason | last post by:
I have compiled libraries as dlls (managed) and I have to uniquely enumerate it (kind of Guid for each one). All of them implements the same interface (see code block) and generate ID each time it...
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!
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!
3
by: pranesh.nayak | last post by:
Hello group, I'm facing a problem in calling a signed .Net class library (c#) from VB6 exe. I have a VB6 exe calling .net assembly. The call to .Net dll works fine when i deploy the .Net...
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:...
5
by: Jim | last post by:
I am trying to compile a demo from the XNA site and I get this error Error 1 Assembly generation failed -- Error emitting 'System.Runtime.InteropServices.GuidAttribute' attribute --'Incorrect...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.