My Fist Live Messenger Add-in : BlogPublisher

Well Its my first experience with live messenger addin. I wrote a blog publishing addin , that reads RSS feed from the blogs or any other site and updates my Personal Status Message on Live Messenger at regular interval (at the moment it updates after 30 secs) .

Introduction:

Windows Live Messenger exposes the Add-In functionality, though its still in beta stages and not fully exposed to the users. However for the developers, it can be enabled by setting up a key in the registry \HKCU\Software\Microsoft\MSNMessenger

Add a  DWORD “AddInFeatureEnabled” and set its value to “1”.

Now Sign in with your windows live messenger, goto options , you will see  a new add-in tab in the left pane.

 

Now comes hard part  or should I say the fun part. You can develop a plug-in for yourself too and its easy. Live Messenger exposes its functionality via MessengerClient.dll, which has been exposed as .net 2.0 assembly. As of now , the Live Messenger supports plug-ins targeted for .net 2.0.

To start developing the plugin, just add the reference of MessengerClient.dll , (you can find it in the msn messenger installation folder, default location is <ProgramFilesDir>\MSN Messenger\MessengerClient.dll).

Create a new project in visual studio 2005, or other IDE you are using, add reference to the dll by browsing to the directory. Messenger exposes its add-in functionality through  IMessengerAddIn Interface. This Interface has one method ,Initialize(MessengerClient). This method is invoked when your add-in is being loaded. Here you will receive a messenger client object. The MessengerClient has following members:

  1. Properties
    • AddInProperties : Information about the AddIn, DisplayName , Private Message , Creator Info.
    • LocalUser : Information about the signed in user.
    • SavedState: Storage for pluging specific data (like settings etc.)
  2. Methods
    • SendActionMessage
    • SendTextMessage
    • SendNudgeMessage
  3. Events
    • IncomingTextMessage
    • OutgoingTextMessage
    • ShowOptionsDialog
    • Shutdown
    • StatusChanged

I think all these members are quite self explanatory. ShowOptionsDialog occurs when the user clicks on the Settings button in the Add-In Screen in Option Dialog.

So Where to start, well create a class , implement the IMessengerAddIn interface and the world is all yours. But watch for the tricky part, Messenger expects the assembly name as per the NamespaceQualified Name of the Addin Type. So if you are implementing the interface in MyTestAddIn, which is in the namespace of MyMessengerAddIns, then your assembly name should be MyMessengerAddIns.MyTestAddIn.dll . yeah yeah I know that’s insane , but its how the add-in works in messenger, might be this behavior change in future as we have the beta right now.

Now invoke your imagination power and do something creative. I worked out a blog publishing plug-in, which will fetch the rss feed from the blogs (which you can specify in the settings box) and then updates your personal messages setting it to the entries in the feed at regular intervals.

 

I wrote a simple RSS reader, which reads the feed from the URL , then parses it into a model, (it only reads selected properties.)  Reading RSS is quite simple , its simply an XML document. You can get the full specification on the Internet, or just view the source of any rss feed in your browser , you will understand the structure easily. I have two timers in my AddIn one for updating the personal message at regular interval and the other for checking the updates on the feed.

Important Notes:

The Messenger AddIn is executed in Internet Zone (so you have very limited permission to do anything, no file access , no internet access 🙂 ) unless you strong name your assembly and install it in the gac. 

To Debug the add-in via Visual Studio Debugger, goto the Project Properties and set the Start Action to start an external program i.e “msnmsgr.exe” it is in the same directory as the MessengerClient.dll. When you run the project in VS,it will invoke the messenger, which in turn load your dll. Install your assembly into gac , after the messenger is invoked and while it is loading your add-in. that way it will not be obstructed by Code Access Security obstacles.

Each Add-In is executed in it own Application Domain , and it is sandboxed , so that it will not harm other  add-ins.

Resources :

Special Thanks to Bart De Smet for his post “Your first Windows Live Messenger add-in” , a very nice and well written tutorial to the add-in functionality. Another excellent article on CodeProjectCreating Windows Live Messenger Addins” by Filip van der Meeren. For RSS reading , “You Own .Net RSS Feed in C#” by James H. Byrd  and RSS 2.0 Framework by Chris Richner are very helpful.

Where to go from here:

well the options are uncountable. I am thinking about writing a secure chat plug-in so that it will encrypt you conversation using some public key algorithm, so that no more msn sniffing can haunt.

Source Code :

I will upload the source code soon , I am looking for some file hosting site, as the wordpress only uploads images and pdf files. Please check back later, or if you need it immediately then just drop me a comment.

Advertisements

15 responses to “My Fist Live Messenger Add-in : BlogPublisher

  1. Hi man,

    Really nice work, I was also looking to do something with messenger a couple of months ago. Do you know something about running messenger in context of some other applicaiton.

    Let me know if you have seen a related article.

    Cool stuff anyway.

  2. thnx a lot bro,

    can u give me some detail about it , what do u meant by context ? is it spawing it from some other application or is it about its integration with other apps.??

  3. bhai tou tou cha gaya hai…..

  4. Could you give me any idea why I get this error msg “..Reference to C:\..client.dll” could not be added. This is not a valid assembly or COM component….Only assemblies with extension dll or COM can be referenced…” when I try to add a reference to MessengerClient.dll in C:\Program Files\MSN Messenger folder.

    I really appreciate for your time and consideration in advance.

  5. Hi, I’ve developed a Messenger add-in for my programming Blog.
    To reply to a question of a user of mine, I ask you this question: this user can’t run the add-in because a System.SecurityException occurs, perhaps because he wants to read data from a file. The add-in contains a strong-name.
    So, do you think tha installing the assembly in the GAC would solve this issue?

    Many thanks,
    Alessandro

  6. yes, adding the assembly to the GAC will resolve your issue.

    when messenger loads a plugin , it creates a sand box by loading a instance of CLR for that messenger. Every add in runs in its own clr instance. By default , the clr runs in Internet security zone, which means it has almost no level of trust.
    when you add your assembly to gac, you are increasing the trust level. and when the messenger loads a assembly which gaced it lowers the security restrictions.

    to successfully achieve the results, first remove the add-in from messenger. gac ur assembly then add the add-in again.

    regards
    faraz

  7. Many thanks. Your technical explanation was very useful. Now the plug-in works fine. I also suggested to my user to try the .NET IsolatedStorage classes for reading/writing files in a sand-boxed environment. This also should work.

    Regards,
    Alessandro

  8. you are welcome.

    i havent played with isolated storage classes yet. thanks for pointing that.

    🙂
    regards
    faraz

  9. Great work – Ill give it a whirl sometime

  10. Hey,
    I had posted an issue sometime back for which I haven’t received any suggestions yet. Could you please give me a hint about where I went wrong here or how can I solve this issue?

    Thanks in advance.

  11. @Guru ,
    well i have already sent you an email on ur hotmail account , i don’t know if you have received that or not, i am copying the response as follows.

    Subject Re:Messenger AddIn query

    ” well I think you are not using windows live messenger, the Add-In support is available only in Windows lIve Messenger.
    as a check do one thing ,try dissembling MessengerClient.dll with ildasm , if it can be dissembled then its a valid assembly.
    also try compiling the code via cmd line. btw .net 2 is minimum required version of the framework.

    let me know about ur findings.

    i hope this might help you.

  12. wow…..all this seems so interesting…i’m def going to giv it a try and wud let u know abt how everything went and which plugin did i cum up with if actually i cum up with one 🙂

  13. offcourse , its damn interesting,
    i just got an idea , using messenger to serve as grid node for a grid cluster [:D],

  14. Could you share the code you have for secure MSN plugin? I stumbled into the feature that MSN doesnt allow to modify incoming messages. (as well as for outgoing ones, but in this case you can at least cancel them and send the ciphers)

  15. I am sorry Gani, i haven’t worked that out yet , I have only blogpublisher plug in right now. let me know if you need that ,I will send it to you,
    btw I will be uploading it in a few days so you can download it directly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s