Home All Groups Group Topic Archive Search About

can't create dll properly

Author
8 Sep 2006 10:32 PM
graphicsxp
Hi,
I'm desperately trying to create a dll, register it and then use it as
an ActiveX object.

My vb.net windows class library :

Namespace myMSN
    Public Class Msg
        Public Sub New()

        End Sub

        Public Function Display() As Boolean
            MsgBox("hello world")
            Return True
        End Function
    End Class
End Namespace


I then use regasm /tlb msn.dll    (the name of my project is called msn
that's why i get a dll called msn.dll when I compile it)

Then when I create my ActiveX in JScript:

var vbDotNetObject = new ActiveXObject("myMSN.Msg");
vbDotNetObject.Display();

I get an error saying that an ActiveX component cannot create an
object.

What am I doing wrong, and at which step ?

Thank you

Author
8 Sep 2006 10:41 PM
moon
Two things...
- 'Register for COM Interop' in the projects properties must be set True;
- Using System.Runtime.InteropServices should be added.


In a VBA module I call it then with:

Dim vbDotNetObject
Dim b as Boolean
Set vbDotNetObject = CreateObject("myMSN.Msg")
b = vbDotNetObject.Display()





Show quoteHide quote
"graphicsxp" <samuelberthe***@googlemail.com> schreef in bericht
news:1157754762.964518.290430@h48g2000cwc.googlegroups.com...
> Hi,
> I'm desperately trying to create a dll, register it and then use it as
> an ActiveX object.
>
> My vb.net windows class library :
>
> Namespace myMSN
>    Public Class Msg
>        Public Sub New()
>
>        End Sub
>
>        Public Function Display() As Boolean
>            MsgBox("hello world")
>            Return True
>        End Function
>    End Class
> End Namespace
>
>
> I then use regasm /tlb msn.dll    (the name of my project is called msn
> that's why i get a dll called msn.dll when I compile it)
>
> Then when I create my ActiveX in JScript:
>
> var vbDotNetObject = new ActiveXObject("myMSN.Msg");
> vbDotNetObject.Display();
>
> I get an error saying that an ActiveX component cannot create an
> object.
>
> What am I doing wrong, and at which step ?
>
> Thank you
>
Author
11 Sep 2006 9:09 PM
graphicsxp
hello moon,
Thanks for helping. I've added ' Using System.Runtime.InteropServices'
as you mentionned, and I also set the option 'Register for COM Interop
to true. Yet if I type the same code as the one you gave me in a excel
macro, I get the error ActiveX component can't create object. Same
thing in my msn script. What am I missing ??? This is totally driving
me crazy now

Any help very appreciated
thanks
moon wrote:

Show quoteHide quote
> Two things...
> - 'Register for COM Interop' in the projects properties must be set True;
> - Using System.Runtime.InteropServices should be added.
>
>
> In a VBA module I call it then with:
>
> Dim vbDotNetObject
> Dim b as Boolean
> Set vbDotNetObject = CreateObject("myMSN.Msg")
> b = vbDotNetObject.Display()
>
>
>
>
>
> "graphicsxp" <samuelberthe***@googlemail.com> schreef in bericht
> news:1157754762.964518.290430@h48g2000cwc.googlegroups.com...
> > Hi,
> > I'm desperately trying to create a dll, register it and then use it as
> > an ActiveX object.
> >
> > My vb.net windows class library :
> >
> > Namespace myMSN
> >    Public Class Msg
> >        Public Sub New()
> >
> >        End Sub
> >
> >        Public Function Display() As Boolean
> >            MsgBox("hello world")
> >            Return True
> >        End Function
> >    End Class
> > End Namespace
> >
> >
> > I then use regasm /tlb msn.dll    (the name of my project is called msn
> > that's why i get a dll called msn.dll when I compile it)
> >
> > Then when I create my ActiveX in JScript:
> >
> > var vbDotNetObject = new ActiveXObject("myMSN.Msg");
> > vbDotNetObject.Display();
> >
> > I get an error saying that an ActiveX component cannot create an
> > object.
> >
> > What am I doing wrong, and at which step ?
> >
> > Thank you
> >