Use Windows Contacts from C#
Contacts.Net is a managed API for working with the new .Contact format introduced with Microsoft Windows Vista. This lets developers incorporate Windows Contacts into their applications using any .Net language, such as C#, VB.Net, C++/CLI, F#, etc., using a
higher level and more strongly typed object model than what's exposed by the
COM IContact APIs
published with the Windows Vista SDK. Long term it is also intended to be a set of reusable widgets for displaying contact data in the context of larger programs,
similar to what the
Patrick Smacchia, the lead developer for the awesome tool NDepend, has graciously sponsored this project with a license to the tool. NDepend provides a powerful view that allows you to understand and fluidly navigate how your project interacts with itself and
dependencies. I've only just begun to scratch the surface of what this tool is capable of and it's already providing me new insights of ways I can improve the codebase. I strongly recommend this highly polished tool. Check it out at
Wow! Contacts.Net has been incorporated into the
Coding4Fun developer kit
(also hosted on Codeplex) :)
This is part of the Visual Studio Express release, and includes lots of useful utilities beyond contacts. The folks at Clarity Consulting have added classes and services on top of the core library - source included - that make using contacts in your app as
easy as dragging items from the toolbar into your app. It even includes a sample address book built on top of it and a quick start guide describing how to create something similar. Very cool stuff! An overview of the entire kit is available at
The version of Contacts used by C4F is based on Contacts.Net code close to the .8 release, so there's additional goodness in current releases that isn't in the dev kit.
There are some articles online using the C4F dev kit:
is a sample that uses the Contacts component to copy your Facebook contacts to your bluetooth phone. (C#, VB.Net)
wrote a vCard preview handler using the dev kit. Sadly it was without using the Contacts library, but he mentions it kindly at the end of the post.
The current release is called 1.0 and was released in August. It's a fully functional API for working with Contacts. It has all the capabilities of the Vista IContact COM APIs exposed so the property collections are strongly typed in addition to providing
access via the property path approach of the native APIs. It contains numerous bug fixes and performance improvements over previous releases of Contacts.Net. This release accomplishes most of what I originally planned with this project, which is reflected
in the version number.
The UI originally intended to be part of this has been forked into another project,
. As such this is still intended to be a developer release. The original loose UI is still present as an example of how the APIs can be used.
Some features contained in Contacts.Net that are more than what is available in the native IContact APIs include
- Import and export from vCard format
- Better group support, including the ability to work with two different types of groups: one is the .group format supported by WAB in Vista, the other is a format using the underlying XML schema that is consumable by clients directly accessing the XML.
- The ability to work with contact collections not rooted in the user's Contacts folder.
- User tile framing consistent with the Vista UI.
- Per-property attribute information.
- UI. For a preview, check out the
- Works on XP.
There's also a secondary release called ContactsBridge (similar to the Vista SDK's VistaBridge). It is purely a .Net wrapper on top of the native IContact APIs accessed via COM Interop. As such bugs and inconsistencies in the Vista implementation are
exposed by it. It is a fork of an older version of the Contacts.Net library when more was being done via interop. It's still hosted here for propsperity as an academic example of a large COM interop library (again, similar to VistaBridge) or for those
who have a need for using wab32 in a more direct way.
If you've been using previous versions of the library these are the
you should be aware of between different versions.
page describes the APIs at a high level.
There is also a
page with simple examples of the library in action.
about the COM interfaces provided with the Windows SDK is also available.
As part of developing this API, I've found some interesting behavior in the native implementation of the IContact APIs. These notes might serve well for developers working with the native APIs. They're archived in the
See other developer tools that are part of Microsoft's shared source initiative at