How to: Debug a Custom Index Connector

Posted Wednesday, September 8, 2010 11:17 AM by CoreyRoth

I have been researching Custom Index Connectors in SharePoint 2010 over the past few weeks.  I have been working with the MyFileConnector sample provided in the SDK, but after I made some changes, I realized it wasn’t immediately obvious how to debug my code.  Luckily, @mwiselka helped me out and pointed me in the right direction.  When it comes to debugging an index connector, timing is critical as well as picking the right process.  In this case it’s not a matter of picking the right w3wp.exe process. It’s a matter of picking the right search process.  If you don’t do the process right, your symbols will never be loaded and your break point will never be hit.

To get started, compile your connector and copy the assembly to the GAC.  Now you need to restart the search service.  It is critical that you restart the service any time you make a change or try to debug again.  I would also do an iisreset as this seems to be required as well most of the time.  If this is your first time installing the custom index connector be sure and follow all of the steps in the SDK which includes making registry changes and configuring the content source.  I usually restart the service from PowerShell or a command prompt.

net stop osearch14

net start osearch14

The process we need to debug is called mssdmn.exe.  When you restart the service you will only see one of these listed in your processes list.

DebugCustomIndexConnectorAttachProcess1

You may be tempted to attach to that process right away and kick off a full crawl of your new content source.  Don’t do that.  It will not work.  When you kick off your first crawl, a second instance of mssdmn.exe is launched.  That is the process you attach to.  I remind you that timing is critical.  After you start the crawl, you need to refresh the process list quickly and attach it if you are trying to catch something early in the process.  It really just depends on the speed of your server, sometimes it takes quite a while for the process to show up.

DebugCustomIndexConnectorAttachProcess2

Notice the new process listed.  Once you attach to the correct process, you should have no issue with your breakpoint being hit.

DebugCustomIndexConnectorBreakPoint

Now, you might be thinking, I’ll just wait and attach to all mssdmn.exe processes that show up.  I thought that might work but it doesn’t.  What I have found is that any time you attach to the original mssdmn.exe process, it causes your breakpoint not to be hit.  I have no idea why it behaves this way, but from what I have seen so far, you only attach to the newly spawned mssdmn.exe process.  If you are having trouble getting the timing right, one thing that @mwiselka recommended was to start a crawl of another content source to spawn the mssdmn.exe process and attach to it.  Then when you do your crawl, it should use the same spawned process.

You would think that you could use something like System.Diagnostics.Debugger.Launch() like I have done with features, but I have had no luck getting that to work.  You can see from my code snippet above, that adding a Thread.Sleep() can be a useful way to buy yourself time to attach to the process as well.  It’s kind of hack, but it does seem to work.  If the above technique doesn’t work, try it again.  Recompile, restart osearch14, and iisreset.  This technique can also be used with regular BCS Custom Connectors as well if you want to debug them while indexing.

Comments

# Twitter Trackbacks for How to: Debug a Custom Index Connector - Corey Roth - DotNetMafia.com - Tip of the Day [dotnetmafia.com] on Topsy.com

Pingback from  Twitter Trackbacks for                 How to: Debug a Custom Index Connector - Corey Roth - DotNetMafia.com - Tip of the Day         [dotnetmafia.com]        on Topsy.com

# re: How to: Debug a Custom Index Connector

Tuesday, September 27, 2011 3:58 PM by Erkan

Thanks, this helped. I had only 1 mssdmn,.exe so it was easier for me.

Do you know if there's a way to access more information about the content source other than the Start Addresses? Like the name of the content source, the schedule information for full and incremental updates, the SSA it belongs to, etc.?

# re: How to: Debug a Custom Index Connector

Tuesday, September 27, 2011 6:05 PM by CoreyRoth

@Erkan  I have to think that there is but I haven't tried myself.  Might take some creative use of the object model.  I would love to hear what you find out.

# re: How to: Debug a Custom Index Connector

Wednesday, September 28, 2011 8:21 AM by Erkan

I'm trying to find out whether the user initiated a full or incremental update. I'll let you know if I find out.

# Corey connector | Kerriganmeats

Wednesday, January 25, 2012 6:25 PM by Corey connector | Kerriganmeats

Pingback from  Corey connector | Kerriganmeats

# re: How to: Debug a Custom Index Connector

Monday, August 20, 2012 8:14 AM by Anna

Hi, Great article.  BTW Have you managed to open any of your files via sharepoint that use the custom protocol?  i.e. the url starts with myfile://

If you click to open one of the returned files on the results page, does it work?  I am having difficulty getting this part to work.

Hope you can help

# re: How to: Debug a Custom Index Connector

Friday, April 10, 2015 9:08 AM by Patrick Lavallee

Hi, great article which has saved me time banging my head for debugging this custom connector

However, I'm having difficulties attaching to the second mssdmn.exe process which doesn't seem to spawn in the process list when launching a full crawl.

I've followed the instructions supplied in this article. Maybe i'm missing something ?

Thank you Corey

Leave a Comment

(required)
(required)
(optional)
(required)