My DLL got created fine (I guess) - no errors in build process.
The "Make Assembly COM-Visible" checkbox is checked.
I then created a vbscript which tried to create an instance of the object:
i.e.
set obj = CreateObject("Test")
However, I always receive the error
"ActiveX can't create object 'Test'"
I tried registering the DLL by using regasm, but still got the error.
Can anyone advise what I am missing?
Sample code for the VB.Net app follows:
<ComClass(Test.ClassId, Test.InterfaceId, Test.EventsId)> _
Public Class Test
#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 = "7d75a31e-3ef9-4b31-9647-1e0f6d3729de"
Public Const InterfaceId As String =
"f19ce7ce-b85f-4d59-a187-c8e3fc9cb67b"
Public Const EventsId As String = "105f085a-2e06-4958-9de2-5aa642f966fc"
#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
Public Function Add(ByVal i1 As Integer, ByVal i2 As Integer) As Integer
Add = i1 + i2
End Function
End Class
Well.. the .vb.com group's for pre-dotNet versions of VB, so if you want
only relevant answers, you can remove that from the crosspost list
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
> I then created a vbscript which tried to create an instance of the object:
> i.e.
> set obj = CreateObject("Test")
I think it should be something like:
Set obj = CreateObject ("ClassLibrary1.Test")
depending on the class and class library names.
--
urkec
hi Jeff,
I went through this last year, making up an "interop" vb.net
assembly to use as an object from vbScript.
The results of my efforts is attached. It works -- at least
on win98.
Caveat emptor: it uses a wshATO "debug dialog" (which is a
proprietary object and not widely available) as a sort of
"immediate window" to show debugging messages. However that
part may be stripped out, you don't need to be informed about
what is happening. Just "keep-the-faith".
Also, the script is using an older vb.net command line compiler,
and an older version of the net framework (i.e., the last version
which worked on win98).
In spite of all those caveats, I suspect that the steps needed
to create a scriptable object with vb.net haven't changed all
that much, so you may be able to get something out of the
script.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
Almost :-)
Set obj = CreateObject ("namespacename.classToInitiateName")
In 80% of the times the namespacename is the same as the assemblyname, but
if you followed the patterns and practices library the rootnamespace should
be the company name
Also a .Net Com object that needs the posibility to be created with
CreateObject must have a public sub new ( you may leave it empty if you do
not need a initializer but it must be there )
regards
Michel
"urkec" <ur...@discussions.microsoft.com> schreef in bericht
news:B329665C-D6F7-4468...@microsoft.com...
I'm trying to achieve the exact same results but cannot seem to get my DLL
registered with regasm. Can you advise on the command line you are using to
register your DLL on a non-development machine?
Also, do you happen to have more than one class in your VB solution?
Are you using Visual Studio 9.0?
You don't seem to have an Interface in your code- some postings I find
indicate you need to define an interface but some postings do not. Can you
tell me what the difference would be? I have tried it both ways but doesn't
seem to make a difference on my target machine.
The DLL works just fine on my development machine where I compiled it but I
believe that is because Visual Studio automatically did the necessary
registrations for me.
Thanks for any comments you can add.