Problem
A search for files and emails containing a word or phrase in their content or name / subject raises an InvalidCastException on processing some of the result set rows.
Detail
When iterating over an OleDbDataReader result set (C# & .Net framework 2.0.50727) from a search on an OleDbConnection to a local WDS 3 on XP Pro SP2, I get an inconsistent return type from OleDbDataReader.GetString(int ordinal). The ordinal matches with ‘DocAuthor’ in OleDbCommand.CommandText = “SELECT … DocAuthor …”. The API docs say the GetString(int ordinal) return type should be string or DBNull, but I get string[] for some rows and so assigning to a string causes an InvalidCastException. Currently I manage this by catching any InvalidCastException and skip that result set row. I notice that the OOTB search UI seems able to handle at least one of the files my code finds a problem with, the downloaded ‘Windows Desktop Search Administration Guide.doc’ in fact.
This seems like a bug to me and I submitted bug ID 250587 against the .NET Framework Library on January 8th 2007, but so far nothing has happened. So I thought I would ask this forum for their collective wisdom on this problem.
Also I need to constrain the search scope for file and email but have not seen an example of how to do that yet; does anyone know
Any help from you clever folks would be most appreciated.
Thanks
Gary

Inconsistent API return type when iterating over WDS 3 search results
Pragmented
System.Author is defined as "System.Author" (DBTYPE_WSTR | DBTYPE_VECTOR)
You can constrain your queries to email by select ... where scope='mapi:' for Outlook,or scope='outlookexpress:' for OE.
Also, check out the SDK and the samples (e.g. DSearch.cs) which should help you out
http://msdn2.microsoft.com/en-us/library/aa965362.aspx
Gerald
Microsoft