views:

533

answers:

4

In VB6, ActiveX DLL is listed as a project template but in VS 2005+ there is no such thing. Where is my good old ActiveX DLL template? Many thanks in advance.

+1  A: 

Try this: http://msmvps.com/blogs/pauldomag/archive/2006/08/16/107758.aspx

It outlines how to create an activex control and use it in a web page. As far as I know there's really no 'ActiveX' project template since .NET does it differently. However you can make your .Net controls visible to the COM world, which the article above illustrates.

David
+2  A: 

A couple of concepts; .NET Assemblies are the functional equivalent to ActiveX DLLs in the .NET langauges. .NET Classes and method can be decorated with attribute that have various meaning in different context. A .NET Assembly can be turned into a ActiveX/COM DLL (or OCX) by using various attributes to assign the correct GUIDs.

A basic overview of setting a .NET assembly use COM is here.

Note that do google searches you should include VB6 .NET and COM (not ActiveX). COM generates more hits as it is the underlying technology behind the ActiveX term.

The MSDN article I linked shows a basic COM setup for a .NET Class. The attribute here is the ComClass Attribute.

<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1

#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 = "6DB79AF2-F661-44AC-8458-62B06BFDD9E4"
    Public Const InterfaceId As String = "EDED909C-9271-4670-BA32-109AE917B1D7"
    Public Const EventsId As String = "17C731B8-CE61-4B5F-B114-10F3E46153AC"
#End Region

    ' A creatable COM class must have a Public Sub New() 
    ' without parameters. Otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' through CreateObject.
    Public Sub New()
        MyBase.New()
    End Sub

End Class

There are other Attributes as well that are especially useful if you trying to subsitute a .NET assembly for an existing COM DLL or OCX. Finally .NET has a lot of different wizards that help you with the tedious details.

RS Conley
A: 

It's not quite clear from you question, but if you want to be able to consume in VB6 (or some other com environment) something created in VS2005, you want to look at the Interop Forms Toolkit. This greatly simplifies interop between VB6 and VS2005. Now if you actually want to distribute those applications, installing what you created becomes a lot more fun (Hints: Don't use the GAC, install the .Net dll in the same directory as your application executable, and learn to use RegAsm.)

If you give a little description what you want to use the ActiveX.dll for (project library or User Control) and what environment you want to use it, more advice can be given.

Kris Erickson
A: 

I don’t know if this is what you are trying to do or not. But if you right click on the Toolbox in Visual Studio, in the popup menu select Choose Item…

When you get the “Choose Toolbox Item” dialog box come up, select the “COM Components” tab and check the COM Component(s) you want to add to the toolbox. I have done this to added the “Windows Media Player” to the toolbox and used it in a C# Winform.

From this dialog you can access any COM, OCX or ActiveX control loaded on you system.

Ron Todosichuk