What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » trying to create a c# COM server

trying to create a c# COM server
Author: Message:
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
O.P. trying to create a c# COM server
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)

.zip File Attachment: comtest.zip (3.28 KB)
This file has been downloaded 237 time(s).

This post was edited on 02-16-2009 at 06:50 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
02-16-2009 06:24 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
trying to create a c# COM server - by -dt- on 02-16-2009 at 06:24 AM
RE: trying to create a c# COM server - by -dt- on 02-19-2009 at 04:57 AM
RE: trying to create a c# COM server - by Dr Nick on 02-19-2009 at 09:39 AM
RE: trying to create a c# COM server - by Eljay on 02-19-2009 at 09:17 PM
RE: trying to create a c# COM server - by -dt- on 02-20-2009 at 12:16 AM
RE: trying to create a c# COM server - by Dr Nick on 02-20-2009 at 06:08 AM
RE: trying to create a c# COM server - by -dt- on 02-20-2009 at 01:03 PM
RE: trying to create a c# COM server - by ShawnZ on 02-20-2009 at 01:37 PM
RE: trying to create a c# COM server - by Spunky on 02-20-2009 at 01:47 PM
RE: trying to create a c# COM server - by -dt- on 02-20-2009 at 02:19 PM
RE: trying to create a c# COM server - by Dr Nick on 02-21-2009 at 01:54 AM
RE: trying to create a c# COM server - by John Anderton on 02-21-2009 at 07:33 AM
RE: trying to create a c# COM server - by ShawnZ on 02-21-2009 at 10:42 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On