Shoutbox

trying to create a c# COM server - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: trying to create a c# COM server (/showthread.php?tid=89204)

trying to create a c# COM server by -dt- on 02-16-2009 at 06:24 AM

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? :P


(attached the project file)
RE: trying to create a c# COM server by -dt- on 02-19-2009 at 04:57 AM

anyone? :(


RE: trying to create a c# COM server by Dr Nick on 02-19-2009 at 09:39 AM

So, its absolutely essential that c# is used for this script?

Trying to help as much as I can here ;)


RE: trying to create a c# COM server by Eljay on 02-19-2009 at 09:17 PM

Umm why are you using CreateObject?

jscript code:
var o = new ActiveXObject("comtest.sniffer");

and everything else works fine :P

ok scrap that, it decided it didn't want to work all of a sudden.

jscript code:
var o = new ActiveXObject("comtest.sniffer");

function OnEvent_Initialize(){
    function o::onPacket(){
        Debug.Trace("Event called!");
    }
    o.run();
}

That should work, Plus! seems to be fussy about initialisation stuff *shrugs*

* Eljay is intrigued by the class name though :P

RE: trying to create a c# COM server by -dt- on 02-20-2009 at 12:16 AM

quote:
Originally posted by Eljay
Umm why are you using CreateObject?

jscript code:
var o = new ActiveXObject("comtest.sniffer");

and everything else works fine :P

ok scrap that, it decided it didn't want to work all of a sudden.

jscript code:
var o = new ActiveXObject("comtest.sniffer");

function OnEvent_Initialize(){
    function o::onPacket(){
        Debug.Trace("Event called!");
    }
    o.run();
}

That should work, Plus! seems to be fussy about initialisation stuff *shrugs*

* Eljay is intrigued by the class name though :P

\o/ it works...
RE: trying to create a c# COM server by Dr Nick on 02-20-2009 at 06:08 AM

ooo Yay, so as for the User is typing notification (and whatever else this can do) when will it be released?

I for one am very eager to use it ;)

Thanks soo much
Nick


RE: trying to create a c# COM server by -dt- on 02-20-2009 at 01:03 PM

quote:
Originally posted by Dr Nick
ooo Yay, so as for the User is typing notification (and whatever else this can do) when will it be released?

I for one am very eager to use it ;)

Thanks soo much
Nick
just got very busy, next week sometime
RE: trying to create a c# COM server by ShawnZ on 02-20-2009 at 01:37 PM

what about 64-bit support in now playing


RE: trying to create a c# COM server by Spunky on 02-20-2009 at 01:47 PM

quote:
Originally posted by -dt-
quote:
Originally posted by Dr Nick
ooo Yay, so as for the User is typing notification (and whatever else this can do) when will it be released?

I for one am very eager to use it ;)

Thanks soo much
Nick
just got very busy, next week sometime


I'll gladly test it. I'm always looking for more fun things to do with sniffing :p
RE: trying to create a c# COM server by -dt- on 02-20-2009 at 02:19 PM

quote:
Originally posted by ShawnZ
what about 64-bit support in now playing
ready to make a new wmp support dll?
RE: trying to create a c# COM server by Dr Nick on 02-21-2009 at 01:54 AM

Next week some time sounds great to me!

Cant wait!

Thanks


RE: trying to create a c# COM server by John Anderton on 02-21-2009 at 07:33 AM

quote:
Originally posted by -dt-
quote:
Originally posted by ShawnZ
what about 64-bit support in now playing
ready to make a new wmp support dll?
As long as Winamp works, I'm happy :P

* John Anderton is starting to regret ordering x64 on his lappy ;(
RE: trying to create a c# COM server by ShawnZ on 02-21-2009 at 10:42 AM

quote:
Originally posted by -dt-
quote:
Originally posted by ShawnZ
what about 64-bit support in now playing
ready to make a new wmp support dll?

not my job :p