Home All Groups Group Topic Archive Search About

Trying to write a COM accessible DLL

Author
12 Dec 2006 1:02 AM
Terry Olsen
Following the instructions here:
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=113

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(ByVal Domain As String)
            outMxRecords = "test1.test2".Split(".")
        End Sub

    End Class

End Namespace

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

The following is my VBScript code:

dim oDLL
set oDLL = Createobject("Test.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 ***

Author
12 Dec 2006 7:56 AM
Michel Posseth [MCP]
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 :
http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/b9974554b8d68a52/ca996d74d250974e?lnk=st&q=michel+posseth+COM+VB.Net&rnum=28#ca996d74d250974e

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


regards

Michel Posseth [MCP] 


Show quoteHide quote
"Terry Olsen" wrote:

> Following the instructions here:
> http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=113
>
> 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(ByVal Domain As String)
>             outMxRecords = "test1.test2".Split(".")
>         End Sub
>
>     End Class
>
> End Namespace
>
> I build the DLL, copy it to the C:\WINNT\System32 directory, then run
> REGASM on it, it tells me "Types Registered Successfully"
>
> The following is my VBScript code:
>
> dim oDLL
> set oDLL = Createobject("Test.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 ***
>