can't create dll properly

G

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
 
M

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()
 
G

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top