Click to See Complete Forum and Search --> : GUID creation


Marraco
July 23rd, 2008, 10:28 AM
I are making an automation addin, following this link:
http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx
It contains this code:# Imports System
# Imports System.Runtime.InteropServices
# Imports Microsoft.Win32
#
# Namespace AutomationAddin
#
# ' Replace the Guid below with your own guid that
# ' you generate using Create GUID from the Tools menu
# <Guid("5268ABE2-9B09-439d-BE97-2EA60E103EF6")> _
# <ClassInterface(ClassInterfaceType.AutoDual)> _
# <ComVisible(True)> _
# Public Class MyFunctions
#
# Public Sub New()
# End Sub
#
# Public Function MultiplyNTimes(ByVal number1 As Double, ByVal number2 As Double, ByVal timesToMultiply As Double) As Double
# Dim result As Double = number1
# For i As Double = 0 To timesToMultiply - 1
# result = result * number2
# Next
#
# Return result
# End Function
#
# <ComRegisterFunctionAttribute()> _
# Public Shared Sub RegisterFunction(ByVal type As Type)
# Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type, "Programmable"))
# Dim key As RegistryKey = Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type, "InprocServer32"), True)
# key.SetValue("", System.Environment.SystemDirectory + "\mscoree.dll", RegistryValueKind.[String])
# End Sub
#
# <ComUnregisterFunctionAttribute()> _
# Public Shared Sub UnregisterFunction(ByVal type As Type)
# Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type, "Programmable"), False)
# End Sub
#
# Private Shared Function GetSubKeyName(ByVal type As Type, ByVal subKeyName As String) As String
# Dim s As New System.Text.StringBuilder()
# s.Append("CLSID\{")
# s.Append(type.GUID.ToString().ToUpper())
# s.Append("}\")
# s.Append(subKeyName)
#
# Return s.ToString()
# End Function
# End Class
# End Namespace
The problem is in the lines:
# ' Replace the Guid below with your own guid that
# ' you generate using Create GUID from the Tools menu
# <Guid("5268ABE2-9B09-439d-BE97-2EA60E103EF6")> _
# <ClassInterface(ClassInterfaceType.AutoDual)> _
# <ComVisible(True)> _
# Public Class MyFunctions But VB.NET express does not have "Create GUID" option in the Tools Menu, I don't know how to create a GUID.
I have found the function System.Guid.NewGuid().ToString() , and I think that I can create a new project, use the function to create a GUID, and replace it on the code.

Is this a correct way?
_

ccubed
July 23rd, 2008, 10:44 AM
It's like what you had to do in MushClient to get a brand new plugin id. :)

It'll work. so it shouldn't matter. Basically, you're doing through code what the full visual studio does through a button click. Not to say that you couldn't make your own guid creator. Never have understood microsoft. Here's the express edition. You can use the full vb language, but we take away things like Automatically created sql connections! WOOO! I have to code an extra three lines, man. :)

Marraco
July 23rd, 2008, 10:56 AM
...
It'll work. so it shouldn't matter. Basically, you're doing through code what the full visual studio does through a button click. Not to say that you couldn't make your own guid creator. Never have understood microsoft. Here's the express edition. You can use the full vb language, but we take away things like Automatically created sql connections! WOOO! I have to code an extra three lines, man. :)Thanks for your answer.

I have found a GUID in the assembly information of my dll, and Copy-Pasted it on the code.
Don't know if that makes sense, just testing.
If it don't work, I gonna try to generate a nother one, And if still it does not work, the I gonna need to lost my time trying to learn what the %&$$· thing is that and how to make it.

adambom
July 24th, 2008, 01:06 PM
Easy way is:

Dim myGuid As Guid
myGuid = Guid.NewGuid

HanneSThEGreaT
July 25th, 2008, 12:50 AM
I have found the function System.Guid.NewGuid().ToString() , and I think that I can create a new project, use the function to create a GUID, and replace it on the code.

Is this a correct way?

Yes, you're on the right track :)