Hello D:
Im trying to create a COM server and let it call events (which the jscript binds to) but the events aren't getting set right (though it works in wscript)
it just errors
Heres working code in jscript using wscript
js code:
o = WScript.CreateObject("comtest.sniffer");
WScript.ConnectObject(o, "o_")
function o_onPacket(){
Wscript.Echo("Event Called!");
}
o.run();
then using plus, I have to use an alternate way to hook up events and then it just fails with
quote:
Error: Object reference not set to an instance of an object. (code: -2147467261)
which means that the event isn't being set....
js code:
o = WScript.CreateObject("comtest.sniffer");
function x(){
function o::onPacket(){
Debug.Trace("Event called!");
}
o.run();
}
x();
Here the code for the COM server
c# code:
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace comtest {
[ComVisible(false)]
public delegate void onPacketAr();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[ComVisible(true)]
public interface CallbackEventInterface {
[DispId(1)]
void onPacket();
}
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IDotNetEventSender {
void run();
}
[ComSourceInterfaces(typeof(CallbackEventInterface))]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class sniffer : IDotNetEventSender {
public sniffer() { }
public event onPacketAr onPacket;
public void run() {
onPacket() ;
}
}
}
help?
(attached the project file)