Exposing .NET events to COM for use in VB6 projects


Mike S.

Hello Everyone,

I have a class that I wrote in Visual Basic .NET (using version
1.0 of the Framework). It exposes one public event. I would like to be
able to declare an instance of the class in a Visual Basic 6.0 project
using the standard "WithEvents" syntax. In the .NET project, I set the
"Register for COM Interop" option in
Project->Properties->Configuration->Build and I wrapped the event
declaration in a public interface definition, and I also set the
ComSourceInterfaces attribute to use the interface. I can reference
the .NET library in VB 6.0 and the event shows up in the Object
Browser, but instantiating the class with WithEvents seems to have no
effect. Here is a stripped-down snippet of the .NET code to show how I
declared and set the COM source interface (note that the vertical
ellipses represent omitted code):


Imports System.Runtime.InteropServices

Public Interface IFtpClientEvents
Sub ClientError(ByVal ErrorString As String)
End Interface

<ComSourceInterfaces(GetType(IFtpClientEvents))> _
Public Class FtpClient


End Class

If anyone needs a more detailed description, let me know.



Cor Ligthert

Hi Mike,

Did you know that there is a newsgroup


However that is not to active therefore you maybe can send this problem
better to the newsgroup and the few who are active in the upgrade newsgroup
are as well active in the newsgroup.


Or crossposted (one message to both)

I hope you find your answer there.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question