Search Wiki:
Use Windows Contacts from C#

Welcome!

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 WAB APIs offer.

Coding4Fun

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 http://msdn2.microsoft.com/en-us/express/future/bb679917.aspx.

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:
This is a sample that uses the Contacts component to copy your Facebook contacts to your bluetooth phone. (C#, VB.Net)
Scott Hanselman 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. (C#)


Current Release

The current release is called .9 and was released in October. It's a fully functional API for working with Contacts. It has all the functionality 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 over previous releases of Contacts.Net.

This is still intended to be a developer release, although it does contain some loose UI. The point of the release is to solicit feedback on the APIs to verify correctness in implementation and design. As the version gets closer to a 1.0 much greater caution will go into making API and design changes. Code written against this version of the library should be easily changed to work with the eventual 1.0 release.

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
  • 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.
  • UI. For a preview, check out the Screenshots page.

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.

For specific details on the features being worked on in anticipation of "Contacts.Net 1.0" the Version Roadmap is being worked on.


If you've been using previous versions of the library these are the Breaking Changes you should be aware of between different versions.

Code

The Class Diagrams page describes the APIs at a high level.
There is also a Sample Code page with simple examples of the library in action.

MSDN documentation 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 Gotchas page.

See other developer tools that are part of Microsoft's shared source initiative at
http://www.microsoft.com/resources/sharedsource/Licensing/Developer.mspx
Last edited Feb 13 at 4:28 PM  by JoeCastro, version 26
Updating...