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) .
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:
- 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.)
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.
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.
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 CodeProject “Creating 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.