Do any of these sound familiar?

"Writing a SharePoint Protocol Handler is way to hard!"

"We have no one on staff that is proficient in C++."

"I've found very little documentation on writing a Protocol Handler."

"The BDC doesn't do everything we need."

Well, then you've come to the right place. With this sample code you can write a Microsoft Office SharePoint Server 2007 Protocol Handler in managed code (C#) using the .NET framework. This is not a 'shim' or 'wrapper', it is 100% pure managed code.

Protocol Handlers are COM components (in-proc servers), traditionally written in C++. .NET allows you to create a class library and expose it as a COM component. Therefore it is possible to create a .NET COM component which will be consumed by the SharePoint search engine (Filter Daemon specifically). This sample is an instance of that approach and contains all classes and declarations necessary to build and register a Protocol Handler written in C#.

That's only the beginning. The interfaces used for a protocol handler can be confusing and tedious. I have created an abstraction class (ContentEnumerator) which insulates Protocol Handler communications from the actual work of accessing your content source by exposing simple enumeration interfaces. It should be possible to populate the 'guts' of your Protocol Handler by simply replacing the 'TODO' comments with actual calls to your data source. But if that does not meet your needs you have the freedom to modify any portion of the project - it's your project!

[Update: I've officially moved this to CodePlex. Please pick up the source and documentation there going forward.]

Good luck and happy crawling!