Mess with Messenger gets the scoop on building Addins for Live Messenger

Mess with Messenger gets the scoop on building Addins for Live Messenger

Anyone who is part of the Live Messenger Beta ( and is interested in building managed addins for Live Messenger should head over to the Mess with Messenger website.  They have managed to get hold of build 8.0.0683 which includes a special tab for Addins under Tools–>options (samples etc are also available from their website).

By default the Addins tab is missing, so you have to enable it via a registry key:


Once enabled, the Addins tab should appear (you will need to exit and restart Live Messenger) after you have signed in.

The next thing you have to do is to build your Live Messenger Addin.  This is relatively easy as there is now a MessengerClient.dll in the application folder for Live Messenger (eg c:Program FilesMSN Messenger).  This is a managed wrapper dll which you need to reference in your addin.

So in summary to create your addin you create a class library project (VB.NET, C# or any other .NET language) and you use Add Reference to select the MessengerClient.dll. You then need to create your addin class with which to access the api though.  This class is called by Messenger when your addin is initialized so it MUST be named the same as your class library (just without the dll).  Do NOT put it in a namespace or it will not be found (for VB.NET developers this means you have to remove the default namespace). This class also must implement the IMessengerAddIn interface (which is in the Microsoft.Messenger namespace – I found it easier just to import this namespace).

Implementing this interface requires the Initialize method into which an instance of the MessengerClient class is passed.  I would suggest holding a reference to this class as you can attach handlers so that you can invoke your code when certain actions/events occur.  The following code is a quick Addin I wrote that shows how you can have event handlers for the various Messenger events.  Note that this is compiled into NickSampleLiveAddin.dll

Imports Microsoft.Messenger

Public Class NickSampleLiveAddin
    Implements IMessengerAddIn

    Private theMessenger As MessengerClient

    Public Sub Initialize(ByVal messenger As Microsoft.Messenger.MessengerClient) Implements Microsoft.Messenger.IMessengerAddIn.Initialize
        Me.theMessenger = messenger

        Me.theMessenger.AddInProperties.Creator = “Nick Randolph @ SoftTeq”
        Me.theMessenger.AddInProperties.Description = “Sample plugin!”
        Me.theMessenger.AddInProperties.FriendlyName = “SoftTeq Addin”
        Me.theMessenger.AddInProperties.PersonalStatusMessage = “Nick’s working on an Addin….”
        Me.theMessenger.AddInProperties.Status = UserStatus.Busy
        Me.theMessenger.AddInProperties.UserTile = My.Resources.Nick
        Me.theMessenger.AddInProperties.Url = New Uri(““)

        ‘AddHandler Me.theMessenger.StatusChanged, AddressOf OnStatusChanged
        ‘AddHandler Me.theMessenger.Shutdown, AddressOf OnShutdown
        ‘AddHandler Me.theMessenger.ShowOptionsDialog, AddressOf OnShowOptionsDialog
        ‘AddHandler Me.theMessenger.OutgoingTextMessage, AddressOf OnOutgoingTextMessage
        ‘AddHandler Me.theMessenger.IncomingTextMessage, AddressOf OnIncomingTextMessage
    End Sub

End Class

Once you have create and compiled your Addin you can go back to Live Messenger and select it in the Addins tab.  In order to debug your Addin you can simply attach Visual Studio to the messenger process (msnmsgr.exe) and go ahead and set breakpoints.

Oh, a couple of last things about Addins:  Live Messenger only seems to be able to run 1 Addin at a time – kind of sux really, hopefully they will change this.  Addins also run in a tight security sandbox, so if you were hoping to do malicious things, think again. Lastly, when an Addin is running you get a message at the top of your messenger windows saying that the Addin is running.

Happy Messengering…

A Couple of Blog references to start the day….

A Couple of Blog references to start the day….

After my morning coffee I sat down to read through what people have been saying while I was asleep last night.  The first thing that grabbed my attention was that Monad had been renamed to PowerShellMitch has started a petition to get the name changed and I figured I’d better blog this for two reasons.  Firstly, if we all blog about the fact that the new name kinda sux it might be changed.  Secondly, even if the name isn’t changed, the more we blog about PowerShell the more relevance it will receive when people do search for it.

The other thing that grabbed me was a blog article by the Windows Mobile Team.  Although this article is somewhat random, it is a trick definitely worth noting if you are building signed mobile applications!!!

Mobile Client Software Factory (Connection Manager)

Mobile Client Software Factory (Connection Manager)

Anyone doing Windows Mobile development should be aware of the fantastic work the team over at OpenNETCF have been doing with the Smart Device Framework.  This has provided missing functionality for both v1 and v2 of the .NET Compact Framework.  Recently they also released a series of application blocks that made application development much easier. 

Now the Patterns and Practices team at Microsoft has come to the table and have started to work with the community to improve support for writing enterprise grade mobile applications.  The project, entitled the Mobile Client Software Factory, is made up of a series of application blocks, a testing framework and the mobile composity UI block.  Up to their 5th community drop, this project is progressing nicely and I would recommend that you take a look.

We will use a simple example to illustrate how the connection manager application block can be used.

   Dim configuration As String = “<Connections>” & _
      ”  <Connection  Type=’CellConnection’ Price=’8’/> ” & _
      ”  <Connection  Type=’NicConnection’ Price=’2’/> ” & _
      ”  <Connection  Type=’DesktopConnection’ Price=’1’/> ” & _
   Dim factory As IConnectionManagerFactory = New ConnMgrApiFactory(configuration)
   Dim conManager As ConnectionManager = factory.Create()

   AddHandler conManager.ActiveNetworkChanged, AddressOf ActiveChanged

In this example we use a connection string (typically stored in a configuration file) which defines a series of connection types with their associated price.  One of the problems that is encountered when writing a occasionally connected application is determining when a web request can be made.  For example if the device is connected via a GPRS connection you would only want to make essential request, queuing less urgent and larger requests until a cheaper connection is made available.  The solution to this problem is very similar to the postal system where you have to purchase sufficient stamps in order to send a package of a given size a certain distance.  In the case of connections each connection type has an associated price.  When making web requests you allocate them a number of stamps.  If the number of stamps is >= the price of the active network the request will be made, otherwise it will be queued until a cheaper network is available.

The XML connection string is passed into the constructor for the ConnMgrApiFactory which implements the IConnectionManagerFactory interface.  The Create method on this interface returns a ConnectionManager that contains a list of networks and connections that are defined for the mobile device.

In addition to exposing the list of networks and connection, the ConnectionManager also exposes the ActiveNetworkChanged event.  We will see later that this event is used by the DisconnectedService application block to automatically invoke queued web requests when a connection with an appropriate price becomes active.

The following diagram illustrates the interfaces and the classes that are currently included in the Connection Manager application block.

The main class that you will need to interact with is the ConnectionManager class.  When the active network event is raised you can access the active network via the ActiveNetwork property.  The Network exposes properties such as IsConnected and a PingComponent that can be used to call DoPing to invoke a ping (this can be used to determine if a certain endpoint can be connected to).

SP1 Beta for the .NET Compact Framework V2.0

SP1 Beta for the .NET Compact Framework V2.0

I guess this is pretty old news already, but since this is an area of interest to me I thought that I should at least add to the clutter on the Internet by blogging the fact that a Beta for SP1 for the .NET Compact Framework has been announced and that more information on the added functionality and bug fixes is available on the team’s blog

SQL goes wild everywhere

SQL goes wild everywhere

Since the release of SQL Server 2005 late last year the mobile devices community have been discussing the usage of the SQL Mobile product for application development.  One of the main discussion points has been the usage of SQL Mobile on platforms other than Windows Mobile.  Now you might say, “not support”, but in actual fact you would be partially wrong.  Not only was SQL Mobile designed to work on the WinXP platform, it is actually supported on WinXP Tablet edition.  Intuitively this makes some sense since a Tablet PC can be thought of (in particular when you consider the UMPC devices) as a large PDA and as such it would be convenient to have the same programming model for both devices. 

So, why has this topic received so much attention, well despite the support for running SQL Mobile on Tablet PCs the licensing states that it cannot be run on the standard WinXP platform.  This means that if one of your clients is using a laptop instead of a Tablet PC then they will not be able to run an application based on SQL Mobile.  When you look at it in this light, the decision to support one, but not the other seems quite silly.

Anyhow, lets cut to the chase – Late last week it was announced that a “new” (in fact rebadged/relicensed would be more appropriate) product line would be added called SQL Server Everywhere Edition.  This was followed up with a useful blog entry by Steve Lasker regarding the details of what this new product line would entail. Basically the up shot will be that you can build mobile applications that target SQL Mobile that will run on Windows Mobile and WinXP, allowing you to easily target PDAs, UMPC, Tablet PCs, Laptops and even Desktop PCs.  Note the limitation (of course) around using SQL/e as the db for your web app!

Presenting Skills 101

Presenting Skills 101

I have lost count of the number of presentations that I have literally fallen asleep in.  Mainly it has nothing to do with the content, since I wouldn’t be there if I wasn’t a little interested in the topic.  99% of the time it has to do with the presenter and their usage of powerpoint.  Ok, so I’m not going to come out and say what you should or shouldn’t do because I don’t actually believe there is one “best way” to present.  Everyone has their own style.  This said, I think some general pointers are always useful so I would like to point people to an article I read today on the do’s and don’ts of using presenting with powerpoint.

Would be interested to here comments from others as to what they thought about this article.


Using PhoneCellBroadcast in WM5 for cheap location aware applications

Using PhoneCellBroadcast in WM5 for cheap location aware applications

A couple of weeks ago a fellow MVP, Mitch Denny, asked me a question about the Notification Broker in Windows Mobile 5.  For anyone not familiar with the Notification Broker it is a mechanism where you can not only query system information about the device, but you can also register for notification when a system property changes.  Anyhow, Mitch’s question was regarding the PhoneCellBroadcast property and the fact that it didn’t seem to be returning any data. 

Despite talking over Messenger I did my best job to look puzzled having never really played around with that particular property. Mitch proceeded to explain that it was supposed to access broadcast messages from the current cell the mobile was connected to.  Interestingly enough, Australia is one of the few places in the world where the networks appear to broadcast useful information.  To access this information you firstly have to do the following (the steps here apply to Windows Mobile 5 and have been tested on both the K-Jam and JasJar – let me know if it does/doesn’t work on other devices):

Start -> Settings
Select Personal tab -> Phone
Select More tab -> Tick the Broadcast Channels checkbox and hit Settings button
Tick the Receive channel list checkbox
Select English from language dropdown
Hit New… button
Enter Cell (or any other description) into Name textbox and 50 (this varies in different countries but should be correct for Australian networks) for the Channel number
Hit Ok
Make sure the new entry in the Select item to receive: list is checked
Hit Ok
Hit Ok (again, which should take you back to the main settings page)
Wait 10-20 secs and you should receive a notification bubble with the name of the Cell (eg Subiaco) in it.

Ok, so now that we can see the cell broadcast, what can we do with it.  Well firstly, the usage is going to be somewhat limited because although in some cases the cell name is the suburb, in others it is a cryptic abbreviation (eg EstVicPrk for East Victoria Park) or simply a placeholder (eg New Coverage which we got somewhere around North Fremantle).  This said, I’m sure that someone will come up with a use for it so the important thing is that we can extract the contents of this message.

For those familiar with the Notification Broker you will be aware that we can extract information about the current system state using the following lines of code:

Dim x as new Microsoft.WindowsMobile.Status.SystemState(SystemProperty.PhoneCellBroadcast)

Alternatively, if we want to be notified every time this property changes we can attach an event handler to the Changed event of the SystemState object.  Unfortunately there is a little documented issue with using either of these techniques.  Unless the PhoneCellBroadcast property has a value you will either experience a NullReferenceException or the CurrentValue method will return nothing.

To get this property to function correctly we need to tweak a registry setting which was kindly given to me by one of the mobility guys, Paul Kormann, at Microsoft. By default if you look at the key HKEY_LOCAL_MACHINESoftwareMicrosoftInboxSvcSMS you will see that there is an entry TreatImmediateModeCBAsClass0SMS which has a value of 1.  As the entry implies a value of 1 (ie true I guess) implies that the system should Treat Immediate Mode Cell Broadcasts (ie the network messages we were receiving earlier) as Class 0 SMS.  As I found out from my quick read of the SMS FAQ a Class 0 SMS is designed to be displayed then discarded (versus a Class 1 (ie normal) SMS which is stored).  The net result is that having this value set gives us the notification bubble we saw from the steps above.  Changing the value of this entry (using either a remote registry editor or a registry editor for the device) to 0 should mean that we can access these messages using the notification broker. 

Ok, so I was happy with this and proceeded to change the registry value.  Unfortunately it didn’t immediately work for two reasons.  Firstly in my playing I had disabled the Broadcast channels (the first checkbox in the above steps).  Secondly I hadn’t reset my device.  So the steps to get this to work are:

Complete steps above to enable Broadcast channels
Change Registry value for TreatImmediateModeCBAsClass0SMS
Reset device

Now for the bad news.  I was pleasantly surprised when this worked on my K-Jam so I was quick to pass on the news to Mitch.  Unfortunately try as he might he couldn’t get the same instructions to work on his JasJar.  John also tried this on the SoftTeq JasJar with the same result.

While we were experimenting we did find a useful area of the Registry. HKEY_LOCAL_MACHINESystemState contains a number of keys relating to the current state of the system.  Of particlar interest to what we were doing was the Phone key.  On my K-Jam, after applying the steps above, there was an entry for Cell Broadcast which contained the most recent cell broadcast.  However on the JasJar this entry never seemed to exist.  Interestingly enough when Mitch manually populated this entry the value was accessible in code (as if it has been correctly received via the notification broker).

I hope this is useful to anyone interested in delievering a cheap location aware application.  If anyone can get this to work with the JasJar please let us know.

Enterprise Development using Patterns and Practices

Enterprise Development using Patterns and Practices

Last night, John presented an overview of the Enterprise Library to the Perth .NET Community of Practice.  It was clear that there were mixed experiences within the audience ranging from those that were working with v2 of the library (1 or 2), those working, in anger, with v1 of the library (half a dozen or so) and those that either won’t admit to it or weren’t using it at all.  Having been involved with a large scale application that didn’t use either the application blocks or the Enterprise Library I can only commiserate with those in the same boat – word of advise… spend the time and money to incorporate the Library into your application.  This doesn’t need to be done all at once, you can bring it in piece by piece, but in the long run it should save you time and ensure your product is more reliable.

Ok, so this said, there are some other things that you should really check out, particularly if you are starting a new application and want some guidance on how to build a consistent user experience.

Composite UI Application Block (here)

Mobile Baseline Architecture Toolkit (here)

Also, touch base with John’s blog as he looks at the various application blocks in the Enterprise Library itself. (For those that missed the presentation last night, the slides should be available on the user group site by the end of the week).