Paul Lassiter
Paul Lassiter

Reputation: 2771

Compile error when using WithEvents and a .NET object

I get a compile error "object does not source automation events" on this line in VB6:

Private WithEvents obj As MyClass

MyClass is a COM-visible .NET class.

What is the cause of this error?

Upvotes: 1

Views: 1400

Answers (1)

Deanna
Deanna

Reputation: 24313

It means that MyClass does not have any public events (accessible via COM Interop).

If the .NET object was created in VB.Net, you can use the standard Event keyword as with VB6. C# will require the event keyword and an associated delegate. COM Interop will handle the conversion between .NET events and COM events.

Upvotes: 2

Related Questions