PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Creating VB.Net COM component to use in VBScript.
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Creating VB.Net COM component to use in VBScript.
![]() |
Creating VB.Net COM component to use in VBScript. |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I am trying to create a VB.Net COM DLL which I can use in VBScript.
I followed the steps in the following article: http://msdn2.microsoft.com/en-us/library/x66s8zcd(VS.71).aspx (I used the method "with COM class template") 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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
"Wake-Up-Jeff" <artvandal8@hotmail.com> wrote in message
news:O1qvlbB$HHA.4584@TK2MSFTNGP03.phx.gbl... > > Can anyone advise what I am missing? > 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 |
|
|
|
#3 |
|
Guest
Posts: n/a
|
"Wake-Up-Jeff" wrote: > 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 |
|
|
|
#4 |
|
Guest
Posts: n/a
|
> I think it should be something like: > > Set obj = CreateObject ("ClassLibrary1.Test") > > depending on the class and class library names. 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" <urkec@discussions.microsoft.com> schreef in bericht news:B329665C-D6F7-4468-848D-D33B4CAE836F@microsoft.com... > > "Wake-Up-Jeff" wrote: > >> 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 > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
OK, thanks for letting me know. I will note for future.
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message news:%23AZGBoF$HHA.4828@TK2MSFTNGP04.phx.gbl... > "Wake-Up-Jeff" <artvandal8@hotmail.com> wrote in message > news:O1qvlbB$HHA.4584@TK2MSFTNGP03.phx.gbl... >> >> Can anyone advise what I am missing? >> > > 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 > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Thanks. That worked perfectly.
Appreciate your assistance. Jeff. "Michel Posseth [MCP]" <MSDN@posseth.com> wrote in message news:e4ZazgP$HHA.1900@TK2MSFTNGP02.phx.gbl... > >> I think it should be something like: >> >> Set obj = CreateObject ("ClassLibrary1.Test") >> >> depending on the class and class library names. > > 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" <urkec@discussions.microsoft.com> schreef in bericht > news:B329665C-D6F7-4468-848D-D33B4CAE836F@microsoft.com... >> >> "Wake-Up-Jeff" wrote: >> >>> 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 >> > > |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Hi Jeff,
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. "Wake-Up-Jeff" wrote: > Thanks. That worked perfectly. > Appreciate your assistance. > Jeff. > "Michel Posseth [MCP]" <MSDN@posseth.com> wrote in message > news:e4ZazgP$HHA.1900@TK2MSFTNGP02.phx.gbl... > > > >> I think it should be something like: > >> > >> Set obj = CreateObject ("ClassLibrary1.Test") > >> > >> depending on the class and class library names. > > > > 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" <urkec@discussions.microsoft.com> schreef in bericht > > news:B329665C-D6F7-4468-848D-D33B4CAE836F@microsoft.com... > >> > >> "Wake-Up-Jeff" wrote: > >> > >>> 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 > >> > > > > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

