G
Guest
I have a VB.NET interface that my managed C++ code is to implement. I seem to
be stuck implementing an event defined in that interface. Does anyone have a
simple code snippet that will show me the basics of what I need to implement?
I've seen all the MSDN articles on implementing events in managed C++ and
I've gotten events to work without issue when implementing all the constructs
myself. I fail miserably when trying to correctly implement an event defined
in a VB.NET interface. It's not clear what's defined implicitly and
explicitly. I need your help.
Let's say we have a trivial VB.NET interface defined (my syntax may be off):
Public Interface ISomethingTrivial
Sub Func1()
Event Loaded()
End Interface
On the managed C++ side I would have:
__gc class MySomethingTrivial : public ISomethingTrivial
{
public:
// Constructor
// Destructor
void Func1() { /* Do something here */ }
// How implement the event here???
}
If I go ahead and implement the add_EventName() remove_EventName() events I
get errors about multiple methods being defined. So I get the gist that these
are created "behind the scenes" for me at compile time. I don't know how to
define the raise_EventName() appropriately as I don't know what else is under
the covers that I need to call. Each time I attempt to implement the event
(incorrectly) I can successfully compile my managed C++ class, but when I go
to instantiate an instance of it in my VB code I get "Cannot call New on a
class listed as MustOverride". I assume I will see this until I correctly
implement the event. Someone out there must have experience with this....
Many thanks for your help. - Brett
be stuck implementing an event defined in that interface. Does anyone have a
simple code snippet that will show me the basics of what I need to implement?
I've seen all the MSDN articles on implementing events in managed C++ and
I've gotten events to work without issue when implementing all the constructs
myself. I fail miserably when trying to correctly implement an event defined
in a VB.NET interface. It's not clear what's defined implicitly and
explicitly. I need your help.
Let's say we have a trivial VB.NET interface defined (my syntax may be off):
Public Interface ISomethingTrivial
Sub Func1()
Event Loaded()
End Interface
On the managed C++ side I would have:
__gc class MySomethingTrivial : public ISomethingTrivial
{
public:
// Constructor
// Destructor
void Func1() { /* Do something here */ }
// How implement the event here???
}
If I go ahead and implement the add_EventName() remove_EventName() events I
get errors about multiple methods being defined. So I get the gist that these
are created "behind the scenes" for me at compile time. I don't know how to
define the raise_EventName() appropriately as I don't know what else is under
the covers that I need to call. Each time I attempt to implement the event
(incorrectly) I can successfully compile my managed C++ class, but when I go
to instantiate an instance of it in my VB code I get "Cannot call New on a
class listed as MustOverride". I assume I will see this until I correctly
implement the event. Someone out there must have experience with this....
Many thanks for your help. - Brett