We have some .NET code that generates an event. The 2nd parameter of the
event is a C# class we derived from EventArgs.
A VC6 C++ client is subscribing to the event, we are using the
IDispEventImpl<> template in ATL, and have specified the
ComSourceInterfacesAttribute on our event generating class, as well as the
InterfaceTypeAttribute(InterfaceIsIDispatch) on our dummy interface for the
event in C#.
We are getting the callback made into C++ with no problem. The problem
occurs when we try to call a method of our EventArgs-derived parameter to
the event callback. When we make a call to say,
get_Name(&bstr); on our EventArgs-derived class in the C++ callback ('Name'
is a property in our EventArgs derived class) we get the following error
from the VC6 de *** :
"The value of ESP was not properly saved across a function call. This is
usually the result of calling a function declared with one calling
convention with a function pointer declared with a different calling
I have tried various settings in Project->Settings->C++->Code
Generation->Calling Convention, with no differences in behavior.
When our test app is in VB6 instead of VC6, we can access the parameters's
methods/properties with no problesm from within the event's callback
Another note, when we implemented this event as a dual interface, and
received it in VC++ via a custom interface (rather than IDispatch), I am
pretty sure we were able to access the parameters methods and properties
with out the above crash. the problem, of course, is that with our COM
interface declared as Dual rather than IDispatch, we were unable to receive
the event in VB6.
Sorry for the long post, but there's no easy way to describe the problem.
Can anybody pinpoint what we are doing wrong so that we can access the event
parameters from C++?
Thanks in advance,