Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catching ActiveX callback in C#

Status
Not open for further replies.

d00ape

Programmer
Apr 2, 2003
171
SE
I’m using a third party ActiveX control in my .NET Application. I manage to handle the callback in unmanaged C++ like this:

class MyCallback : public ICallback
{

void OnComplete() {…}
}


MyCallback *callback = new MyCallback();
someobject->SomeFunction(“just a string”, callback);

The function OnComplete is apart of the ICallback interface.
In C++ the method OnComplete will be called some seconds after SomeFunction has been called.

How do I translate that into C#?

I’ve come this far:

public class MyCallbackSC : ICallback
{

void OnComplete() {…}
}


MyCallback callback = new MyCallback();
someobject.SomeFunction(“just a string”, (object)callback);

My C# program compiles fine but when I got an exception on the codeline above that says: InvalidCastException.

Anyone got any ide how to handle callbacks in C#...?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top