Unable to cast COM object of type
Hello,
I tried to a function wrapper for my website which calls ExecuteQuery(...). I got this error when I tried to display the output from the internet browser:
Unable to cast COM object of type 'Microsoft.Windows.DesktopSearch.Query.SearchDesktopClass' to interface type 'Microsoft.Windows.DesktopSearch.Query.ISearchDesktop'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A227843C-1D92-48BC-AED6-DCA566F1790E}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Any hint?
Fokus
[618 byte] By [
Fokus] at [2008-3-7]
Hi,
I decided to upgrade my WDS with the latest version.
I tried the my code with the lastest "Windows Desktop Search version 02.06.0000.2083".
Unfortunately, I am still not able to get it right.
The idea is as follows:
index.aspx calls a function (getNumDocsFromAQuery(...)) in a C# (utils.cs) file.
In this function, it invokes ExecuteQuery(...).
Any hint?
//Utils.cs File
public int getNumDocsFromAQuery(string mystr)
{
if (mystr == "")
{
return 0;
}
QueryBuilder myQuery = new QueryBuilder();
myQuery.clearColumns();
myQuery.addColumnList(ColumnType.GeneralColumnList);
myQuery.addColumnList(ColumnType.MusicColumnList);
myQuery.addColumnList(ColumnType.ImageColumnList);
myQuery.sortColumn = ColumnType.GeneralColumns.DocTitle;
string typeFilter;
typeFilter = TypeFilter.Email;
myQuery.ExecuteQuery(mystr, typeFilter);
int result = myQuery.resultSet.Tables[0].Rows.Count;
return result;
}
These are the error messages from the internet explorer:
========================================================
QueryInterface for interface Microsoft.Windows.DesktopSearch.Query.ISearchDesktop failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: QueryInterface for interface Microsoft.Windows.DesktopSearch.Query.ISearchDesktop failed.
Source Error:
Line 27: int numLocalDocs = myutils.getNumDocsFromAQuery("Hello");
Source File: C:\Inetpub\wwwroot\myweb\index.aspx Line: 27
Stack Trace:
[InvalidCastException: QueryInterface for interface Microsoft.Windows.DesktopSearch.Query.ISearchDesktop failed.]
Microsoft.Windows.DesktopSearch.Query.SearchDesktopClass.ExecuteQuery(String lpcwstrQuery, String lpcwstrColumn, String lpcwstrSort, String lpcwstrRestriction) +0
Microsoft.Windows.DesktopSearch.SampleWrapper.QueryBuilder.ExecuteQuery(String query, String filterclaus) in C:\Documents and Settings\fokus\My Documents\myprojects\myprojects\myPersonalizedSearch\mypSearch\pSearch.API\QueryBuilder.cs:129
pSearch.API.Utils.getNumDocsFromAQuery(String mystr) in c:\documents and settings\fokus\my documents\myprojects\myprojects\mypersonalizedsearch\mypsearch\psearch.api\utils.cs:294
ASP.index_aspx.retrievePages(Object sender, EventArgs e) in C:\Inetpub\wwwroot\myweb\index.aspx:27
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Fokus
All I want is to make a query and get the total number of documents in my local drive that contain the same keywords. I need to use an internet browser to let the user type his/her query.
If Microsoft Desktop Search does not allow me to do that, what are other alternatives I can use?
Please assist! Thank you!
Haward
Unfortunately the current version of the SDK doesn't provide the necessary proxy stubs to support calling from certain contexts (including certain threading models, services, and ASP .NET applications).
We're bringing on new people to help with work on an improved SDK which will address this problem (among others), however I don't have an ETA at this point.
Any word on when this will be done so I can use it in a console app? Word came down from "on high" yesterday that we have to start scouring all our systems for SSN data, and I need this to not throw a casting exception in a console application. Thank you!
I would use 3.0 B2, but we need this today, not when Vista is installed on all our boxes in a year... aghhhh.
Aha, I just met the same problem.
Finally, I solved this problem by add [STAThread] before static int Main(string[] args).
I tried that but it didn't work on my console app. I tried [STAThread]... hmmm
Have you add WDSQuery.dll in Reference?
Here is my code:
[STAThread]
static int Main(string[] args)
{
int result = RunStablityTests();
return result;
}
I guess you can create a window application and try your code again.
i have the same problem.
i have a web service, and a c# class.
the class is from the microsoft sdk example, and the webservice just call the ExecuterQuery method, and returns a dataset.
then i have a new winform project and i set a web reference to my webservice.
my winform calls a method in the webservice that calls the ExecuteQuery in the class.
then i recive the err msg.
i set a reference in my winform to the wdsquery.dll, but i still recive the errmsg.
help please...
shimshon wrote: |
i have the same problem. i have a web service, and a c# class. the class is from the microsoft sdk example, and the webservice just call the ExecuterQuery method, and returns a dataset. then i have a new winform project and i set a web reference to my webservice. my winform calls a method in the webservice that calls the ExecuteQuery in the class. then i recive the err msg. i set a reference in my winform to the wdsquery.dll, but i still recive the errmsg. help please... |
|
You can enter a blank line in your master page, then delete it, rebuild your program and your code should work after that.