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?
_
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?
_