C
Csaba Árpádházy-Godó
Guest
Hi everyone!
As a visually impaired programmer mainly I develop scripts for screen reader programs (JAWS & NVDA) to make easier to use other Windows programs & apps with these screen readers. Currently I'm developing scripts for JAWS. Its script language (which is derived from Basic) can accept COM objects as "functionality extender". Until recently I developed my "extenders" in VB6 as ActiveX dll's. They worked correctly with JAWS. But now I decided to "upgrade" to .NET and tried to make my first com visible interop class in Visual Basic 2019 with the Visual Studio Community 2019. I have read every MS walktroughs and other available sources on the net before I began to write my code.
After compiling to a release version I tried It with JAWS but did not work. I got the error message, that ActiveX component can't create the object.
Because VB6 was installed on my machine I thought I took a try with it, too and I wrote a small test program, which is worked correctly. My interop COM object was created and the simple test message was displayed. Finally I decided to write the same test program in VBScript,, too, what did not work, like in JAWS. I got the same error message. (Generaly COM objects working with VBScript works also with JAWS.)
I use a 64-bit machine with Windows 10 1709.
What could be the problem? Why works with VB6 and why not with JAWS & VBScript?
My code:
(My COM dll)
• IComClassInterface.vb file
Public Interface _ITester2
Sub TestMessage()
End Interface ' _ITester2
• ComClass.vb file:
Imports System
Imports System.Runtime.InteropServices
<ComClass(Tester2.ClassId, Tester2.InterfaceId, Tester2.EventsId)>
Public Class Tester2
Implements _ITester2
#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 = "3d640e73-5ea4-4b49-a7ca-42886925d2b5"
Public Const InterfaceId As String = "04aa4001-e8b9-4dcf-86a8-77c7e101245f"
Public Const EventsId As String = "e2f8a2e0-c42e-469f-8a55-bf853ff7ca2b"
#End Region
' 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 ' New
Public Sub TestMessage() Implements _ITester2.TestMessage
MsgBox("This is a test message from the COM object.")
End Sub ' TestMessage
End Class ' Tester2
Test code (in VB6) what worked:
Option Explicit
Sub Main()
Dim oTest As COMClassTest2.Tester2
Set oTest = New COMClassTest2.Tester2
oTest.TestMessage
Set oTest = Nothing
MsgBox ("Ez a vége.")
End Sub
• Test code in VBScript (hwat not worked)
Option Explicit
Dim oTest
Set oTest = CreateObject("COMClassTest2.Tester2")
oTest.TestMessage
Shepherd Godson -------------------------------------------------------- A simple blind developer mastering development of accessible applications for his soulmates
Continue reading...
As a visually impaired programmer mainly I develop scripts for screen reader programs (JAWS & NVDA) to make easier to use other Windows programs & apps with these screen readers. Currently I'm developing scripts for JAWS. Its script language (which is derived from Basic) can accept COM objects as "functionality extender". Until recently I developed my "extenders" in VB6 as ActiveX dll's. They worked correctly with JAWS. But now I decided to "upgrade" to .NET and tried to make my first com visible interop class in Visual Basic 2019 with the Visual Studio Community 2019. I have read every MS walktroughs and other available sources on the net before I began to write my code.
After compiling to a release version I tried It with JAWS but did not work. I got the error message, that ActiveX component can't create the object.
Because VB6 was installed on my machine I thought I took a try with it, too and I wrote a small test program, which is worked correctly. My interop COM object was created and the simple test message was displayed. Finally I decided to write the same test program in VBScript,, too, what did not work, like in JAWS. I got the same error message. (Generaly COM objects working with VBScript works also with JAWS.)
I use a 64-bit machine with Windows 10 1709.
What could be the problem? Why works with VB6 and why not with JAWS & VBScript?
My code:
(My COM dll)
• IComClassInterface.vb file
Public Interface _ITester2
Sub TestMessage()
End Interface ' _ITester2
• ComClass.vb file:
Imports System
Imports System.Runtime.InteropServices
<ComClass(Tester2.ClassId, Tester2.InterfaceId, Tester2.EventsId)>
Public Class Tester2
Implements _ITester2
#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 = "3d640e73-5ea4-4b49-a7ca-42886925d2b5"
Public Const InterfaceId As String = "04aa4001-e8b9-4dcf-86a8-77c7e101245f"
Public Const EventsId As String = "e2f8a2e0-c42e-469f-8a55-bf853ff7ca2b"
#End Region
' 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 ' New
Public Sub TestMessage() Implements _ITester2.TestMessage
MsgBox("This is a test message from the COM object.")
End Sub ' TestMessage
End Class ' Tester2
Test code (in VB6) what worked:
Option Explicit
Sub Main()
Dim oTest As COMClassTest2.Tester2
Set oTest = New COMClassTest2.Tester2
oTest.TestMessage
Set oTest = Nothing
MsgBox ("Ez a vége.")
End Sub
• Test code in VBScript (hwat not worked)
Option Explicit
Dim oTest
Set oTest = CreateObject("COMClassTest2.Tester2")
oTest.TestMessage
Shepherd Godson -------------------------------------------------------- A simple blind developer mastering development of accessible applications for his soulmates
Continue reading...