Shoutbox

Programming with C# - 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)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Programming with C# (/showthread.php?tid=45661)

Programming with C# by white-knight on 06-02-2005 at 02:16 AM

Does anyone write plugins in microsoft visual c# .NET?
If so would I be able to get ahold of the source code, I would like to learn and have beginners knowlege of c# but i havent quite figured out this plugin stuff yet


RE: Programming with C# by Patchou on 06-02-2005 at 03:27 AM

The plugins package includes a sample in VB.NET... it should be fairly easy to translate it into C# :).


RE: Programming with C# by J-Thread on 06-02-2005 at 12:09 PM

I'm also trying to do it. Translate the other plugins to C# wasn't a problem. I've got this:

code:
using System;

namespace Test
{
    public class TestPlugin
    {
        public TestPlugin()
        {

        }

        public bool Initialize(long nVersion, string sUserEmail, object oMessenger)
        {
            return true;
        }

        public bool GetPublishInfo(ref string sPluginNameString, ref long nCommandCount, ref long nTagCount)
        {
            sPluginNameString = "Test Plugin";
            nCommandCount = 1;
            nTagCount = 0;
            return true;
        }

        public void GetPublishCommandInfo(long nCommandIdx, ref string sName, ref string sValue, ref string sHelp)
        {
            if(nCommandIdx == 1)
            {
                sName = "Test option";
                sValue = "xtest";
                sHelp = "Some help text";
            }
        }

        public void GetPublishTagInfo(long nTagIdx, ref string sName, ref string sValue)
        {

        }

        public bool ParseCommand(string sCommand, string sCommandArg, object oConversationWnd, ref string sResult)
        {
            if(sCommand.ToLower() == "/xtest")
            {
                sResult = "It works! You said: " + sCommandArg;
                return true;
            }

            return false;
        }
    }
}

But the problem is installing... I can't install it correctly...

I know how to do it but it doesn't work... I first unload the messenger plugins, then I copy the dll to the correct map, after that i write the registry key and then I use RegAsm to register my key. But i keep having errors about having 2 instances of mscoree.dll (or something like that) loaded... And msn crashes. One time it worked when I closed msn first, but that doesn't work all the time. I think the problem is, it takes too long to copy the dll and regasm it, so msgplus has already loaded it... But i'm not quite sure. Anybody has got an idea?
RE: Programming with C# by RaceProUK on 06-02-2005 at 01:48 PM

If it works when you close Messenger before doing all the copy+reg schniz, then why not keep doing that? It may annoy your contacts a bit, but then you can have your main profile on WebMessenger, and a second profile on MSN Messenger.


RE: Programming with C# by J-Thread on 06-02-2005 at 04:32 PM

But it should work while msn is running! How do people do it...


RE: Programming with C# by (CyBeRDuDe) on 06-02-2005 at 07:55 PM

What reloader are you using?... If you use Plugin Reload By TheBlasphemer it unloads the plugins, then gives you a messagebox and the plugins will first be reloaded WHENl you click the ok botton on that messagebox.. this way you can be sure that there is time enough... If this still doesn't work then the timing is correct... Do you have any other plugins installed?.. Some plugins might crash Messenger when using a reloader, I'm still not sure why, but some does.. You will then have to follow this advise that Optimism gave in another thread:

quote:
Originally posted by optimism_
all it does is tells messenger plus! to reload the plugins using the information in the API.

If messenger crashes it is because one or more of the plugins dies. Therefore, you gotta do try each dll out, see which one causes the error.

rename ALL dlls except pluginreloader.dll to .dl.bak.
then reload
then rename ONE dll at a time back to .dll and reload again

When messenger crashes, the dll that you just renamed is the one that isnt working properly. You should upgrade or delete this plugin.
quote:
Originally posted by optimism_
presumably when it crashes itll be no longer running. therefore you can name them all to .bak before you restart it

{
Then rename a .bak to a .dll (they wont be locked at this point will they)
And reload
}//Repeat until the culpret is  found


Hope this will work for you?
RE: Programming with C# by RaceProUK on 06-02-2005 at 09:31 PM

quote:
Originally posted by (CyBeRDuDe)
Some plugins might crash Messenger when using a reloader, I'm still not sure why, but some does..
It depends on what they do, and whether they unload themselves properly. I know for certain that if you don't unsubclass a subclassed window, when the plugin is unloaded, MSN crashes as it tries to call a function that's no longer there.
RE: Programming with C# by J-Thread on 06-02-2005 at 10:40 PM

Tnx, i'll try that one!! I'm not using that reloader, i just broadcast "MessengerPlus_PluginChange". I'm almost sure it works, because when i don't send it, nothing happens because the new plugin isn't loaded untill i restart msn... Hmmm maybe first copy the dll, register it, and after that sending the windows message?

By the way, i'm using 2 plugins, the handwriting plugin (an old version i think, but it works correctly) and the Reverse Plugin made by myself (http://www.msgplus.net/pluginsdb/down/pafiledb.php?action=file&id=85). That may be the point, it is made in VB6... So that might be the old dll... I will try it tomorrow!! Tnx for your answers. When it all works properly i will post my Inno Setup code here also... Make a tutorial.
Maybe it's an idea to include an Inno Script example in the messenger plus plugin api? It will be usefull for beginning programmers i think... For those who don't know Inno Setup, see http://www.innosetup.com. It's the best setup you can have I think, you can do everything you want!! :D


I did a few tests today, and the problem is not the other plugins. It acts exactly the same when there are no other plugins...

But there should be anybody who made a proper setup for a VB.NET or C#.NET plugin don't you guys think?? By the way, it doesn't work anymore when I close MSN first... As soon as I start msn it gives an error about two different copy's of a dll...

I searched the forums and there is somebody who had about the same problem, he talked about "two versions of the .NET framework". Well i only got one version as far as I know, and that's 1.1....

Is there nobody who know a solution for this problem?
RE: Programming with C# by RaceProUK on 06-03-2005 at 03:51 PM

Make sure you haven't accidentally registered the DLL in two different locations.

Edit: What DLL is it complaining there's two copies of?


RE: Programming with C# by J-Thread on 06-04-2005 at 07:07 PM

I made a new project in C#.NET, copy'd the code, changed all the names, then close msn, and execute the setup. It still gives an error, so it's not registered twice, that isn't possible because I just made it and haven't done anything else with it...

In the attachment the error i get when i start msn after installing...

[Image: attachment.php?pid=474051]


RE: Programming with C# by RaceProUK on 06-04-2005 at 07:40 PM

First, attach GIFs or PNGs if you want to post screenshots.
Second, given that the first occurence of the DLL is '<Unknown>', you may wish to check the .NET Framework is installed correctly.


RE: Programming with C# by J-Thread on 06-05-2005 at 08:14 AM

Sorry for the bitmap, I know it but i had too less time so i didn't notice it was a bmp...

In the attachement my compiled setup, this should work on other's computers if it indeed is my .NET Framework. But i doubt it because i never had any problems with it, and this is the first time I ever see this error. So i'm almost sure it is something in this plugin / setup... And if you want to test it, make sure you have Messenger Plus and a version of the .NET Framework installed, i didn't make error messages or check's for it so if you haven't got them both you absolutely will get strange errors... But if this is working i'll do a check for those.

I hope somebody will test this and have a good solution...


RE: Programming with C# by RaceProUK on 06-05-2005 at 01:06 PM

I got the message on my machine. So I'm guessing it's a problem with the actual linking stage of compiling. I'm not sure exactly what's happened, but I guess it could be something like MSCOREE.DLL has been statically linked, and is also dynamically loaded at runtime. That would go some way to explaining the '<Unknown>'.

Don't quote me on this: it's just a semi-educated guess.


RE: Programming with C# by J-Thread on 06-05-2005 at 02:18 PM

Found something:

http://blogs.msdn.com/robgruen/archive/2005/04/14/408209.aspx

I did that but it stil doesn't work :|


RE: Programming with C# by J-Thread on 06-07-2005 at 09:23 AM

I absolutely don't know how it is possible, but I just installed the plugin while msn was running, and it did work. I used exactly the same code (at least as far as I know), I only recompiled it...

So I did it good, i'm gonna test now how it is possible... And after that I'll write a tutorial about making C#.NET plugins:)


RE: Programming with C# by J-Thread on 06-07-2005 at 10:59 AM

I absolutely can't understand what is happening here...

As I said, it just worked, and with the same setup I can't get it working anymore... I didn't change anything, and now it isn't working. Sometimes I get the error, sometimes msn just closes, sometimes there isn't an error at all, everything works, but the plugin isn't added, and this morning one time it all worked as expected, but i can't reconstruate it...:S

Is there absolutely nobody who made a working setup for a C#.NET plugin?? I know it is possible, but i still don't know how I did it:S:|


RE: Programming with C# by RaceProUK on 06-07-2005 at 10:31 PM

Ever heard of editing?