aTekTipsUser
Programmer
I am trying to create a com library in vb.net. I have copied the example in Visual Studio Walkthrough:
Walkthrough: Creating COM Objects with Visual Basic .NET
Step 1 - 2 Create new project
Step 3. Select add new Item...
Step 4. Select COM class from the Templates list...
Step 5. Add code...
Step 6. Select Build Solution from the Build menu. Visual Basic .NET builds the assembly and registers the COM object with the operating system.
Here is the code:
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "3E7D58F9-7BC7-41E6-8D59-8CE319CDB094"
Public Const InterfaceId As String = "B9BE411A-83CE-4023-B330-766828937787"
Public Const EventsId As String = "BD9FF711-EB89-41E8-8401-BF0F1CF8284A"
#End Region
Private _test As String
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public Property GetTest() As String
Get
Return _test
End Get
Set(ByVal Value As String)
_test = Value
End Set
End Property
End Class
When I run from Access I get the error:
Run-time error -2147024713' Automation error Cannot create a file when the file already exists.
Here is the code in Access:
Dim c As ComClassTest.ComClass1
Set c = New ComClassTest.ComClass1
MsgBox c.GetTest
The error occurs at Set C = New...
Thanks in advance for your help!
Walkthrough: Creating COM Objects with Visual Basic .NET
Step 1 - 2 Create new project
Step 3. Select add new Item...
Step 4. Select COM class from the Templates list...
Step 5. Add code...
Step 6. Select Build Solution from the Build menu. Visual Basic .NET builds the assembly and registers the COM object with the operating system.
Here is the code:
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "3E7D58F9-7BC7-41E6-8D59-8CE319CDB094"
Public Const InterfaceId As String = "B9BE411A-83CE-4023-B330-766828937787"
Public Const EventsId As String = "BD9FF711-EB89-41E8-8401-BF0F1CF8284A"
#End Region
Private _test As String
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public Property GetTest() As String
Get
Return _test
End Get
Set(ByVal Value As String)
_test = Value
End Set
End Property
End Class
When I run from Access I get the error:
Run-time error -2147024713' Automation error Cannot create a file when the file already exists.
Here is the code in Access:
Dim c As ComClassTest.ComClass1
Set c = New ComClassTest.ComClass1
MsgBox c.GetTest
The error occurs at Set C = New...
Thanks in advance for your help!