Set event to ActiveX control?

I create ActiveX control by following code:

Type type = Type.GetTypeFromProgID(PROG_ID, true);
object axObj = System.Activator.CreateInstance(type);

and call method by following code:

type.InvokeMember("MethodName", System.Reflection.BindingFlags.InvokeMethod, null, axObj, new object[] { });

How can I set event callback function to ActiveX object?
[389 byte] By [Goldbach] at [2007-11-20 10:52:44]
# 1 Re: Set event to ActiveX control?
think you need to provide the metadata/typelib of the com activex control. anyway, why not use early-binding?
Thread1 at 2007-11-9 11:36:02 >
# 2 Re: Set event to ActiveX control?
I try:

ActiveX Callback prototype:
void Callback(BSTR Message, BSTR Device, INT Type);

C#:
private delegate void Fn_Callback(System.String str1, System.String str2, int nValue);

private static void Callback(System.String str1, System.String str2, int nValue)
{
}

Class()
{
Type type = Type.GetTypeFromProgID(PROG_ID, true);

object axObj = System.Activator.CreateInstance(type);

Fn_Callback fn_Callback = new Fn_Callback(Callback);

type.InvokeMember("Callback", System.Reflection.BindingFlags.SetProperty,
null, axObj, new object[] { fn_Callback });
}

System throw InvalidCastException when call InvokeMember(...).
I don't know why it occurred and how to debug it.
Goldbach at 2007-11-9 11:37:02 >
# 3 Re: Set event to ActiveX control?
is the controls "Callback" a property?? anyway, have a look at this article http://www.codeproject.com/csharp/zetalatebindingcomevents.asp it may help.
Thread1 at 2007-11-9 11:38:01 >
# 4 Re: Set event to ActiveX control?
I try to use JavaScript to set callback, it's success.
This is my JavaScript code.

<OBJECT ID="axObj" CLASSID="CLSID:007E5DAE-620F-11D4-88E3-005004524698"></OBJECT>

<SCRIPT Language="JScript">

onload=Init;

function Init()
{
axObj.Callback = Callback;
}

function Callback(str1, str2, nValue)
{
}

</SCRIPT>
Goldbach at 2007-11-9 11:39:07 >