Trying to write a COM accessible DLL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olsen

    #1

    Trying to write a COM accessible DLL

    Following the instructions here:


    The following is my ClassLibrary code:

    Imports System

    Namespace Test

    Public Class Test2

    Public Sub Test3()
    End Sub

    Private outMxRecords As String()

    Public ReadOnly Property MxRecords() As String()
    Get
    Return outMxRecords
    End Get
    End Property

    Public Sub GetMxRecords(By Val Domain As String)
    outMxRecords = "test1.test2".S plit(".")
    End Sub

    End Class

    End Namespace

    I build the DLL, copy it to the C:\WINNT\System 32 directory, then run
    REGASM on it, it tells me "Types Registered Successfully"

    The following is my VBScript code:

    dim oDLL
    set oDLL = Createobject("T est.Test2")
    if err.number<>0 then
    msgbox "ERROR " & err.number & " opening DLL"
    else
    msgbox "Success"
    end if

    When I run the script, I get the following error:

    ActiveX component can't create object: 'Test.Test2'

    Error code is 800A01AD

    I can't see anything wrong with this. Hopefully someone here can help me
    out.

    *** Sent via Developersdex http://www.developersdex.com ***
  • Michel Posseth [MCP]

    #2
    RE: Trying to write a COM accessible DLL

    well i see already one thingy you missed

    A com creatable class must have a parameterless public sub new

    here is an example i once showed in this newsgroup :



    "csharpfrie nds" you could have known this wouldn`t work in VB ;-)


    regards

    Michel Posseth [MCP]


    "Terry Olsen" wrote:
    Following the instructions here:

    >
    The following is my ClassLibrary code:
    >
    Imports System
    >
    Namespace Test
    >
    Public Class Test2
    >
    Public Sub Test3()
    End Sub
    >
    Private outMxRecords As String()
    >
    Public ReadOnly Property MxRecords() As String()
    Get
    Return outMxRecords
    End Get
    End Property
    >
    Public Sub GetMxRecords(By Val Domain As String)
    outMxRecords = "test1.test2".S plit(".")
    End Sub
    >
    End Class
    >
    End Namespace
    >
    I build the DLL, copy it to the C:\WINNT\System 32 directory, then run
    REGASM on it, it tells me "Types Registered Successfully"
    >
    The following is my VBScript code:
    >
    dim oDLL
    set oDLL = Createobject("T est.Test2")
    if err.number<>0 then
    msgbox "ERROR " & err.number & " opening DLL"
    else
    msgbox "Success"
    end if
    >
    When I run the script, I get the following error:
    >
    ActiveX component can't create object: 'Test.Test2'
    >
    Error code is 800A01AD
    >
    I can't see anything wrong with this. Hopefully someone here can help me
    out.
    >
    *** Sent via Developersdex http://www.developersdex.com ***
    >

    Comment

    Working...