Dlls
-
Yes, so long as they expose CCWs, or COM-Callable Wrappers (which is the best way, and VB6 is entirely built on OLE/COM anyway). See Nick's article, Creating a CCW for COM-enabled, non-.NET Applications[^], and read Exposing .NET Framework Components to COM[^] in the .NET Framework SDK. A few important things to note: explicitly define your class and interfaces GUIDs (using the
GuidAttribute
), and DO NOT use auto-generated class interfaces. Instead, attribute your class withClassInterface(ClassInterfaceType.None)
and explicitly declare your class interface and implement it as the first interface in the list of interfaces. Make sure you declare your interface as an automation interface by attributing your interface withInterfaceType(ComInterfaceType.InterfaceIsIDispatch)
(orComInterfaceType.InterfaceIsDual
). Since VB6 depends on automation, declaring your interface as an IUnknown implementation won't work.Microsoft MVP, Visual C# My Articles
-
Yes. You'll need to use regasm.exe to register your assembly as a COM dll. Depending on what the public interface looks like you might have to decorate your code with attributes. There is a lot of information and examples on the web. You can also take advantage of COM+ services in the
System.EnterpriseServices
namespace.