Hi everyone,
While you can do COM-visible components in .NET, you unfortunately cannot do
OCX (ActiveX) *controls*. OCX/ActiveX involves a little bit more than a
non-visual COM components, namely a set of pre-defined interfaces which
should be properly implemented by the control to cover the communication
between the control and its site. For example, you can take a look at
interfaces such as IOleClientSite and IOleWindow (the spelling might be not
100% correct, it's been more than a year ago I dealt with these).
From what I remember, in early versions of the framework, the
System.Windows.Forms.Control class used to implement these interfaces, but
at some point Microsoft decided not to support them anymore.
As a workaround, you can use a so-called "shim control". This is a small
ActiveX control written in C++ which should be available free of charge in
the "Files" section of the "vsnetaddin" Yahoo group. This shim control is
used by add-in developers to host .NET Windows Forms controls as ActiveX
controls inside IDE's tool windows.
If your C# code is not UI-related, you can indeed compile and register it as
a COM-visible assembly, and then to create the visual part in, say, Visual
Basic 6, and to reference the C#-written COM DLL from the VB6 project.