Abro Gaticus
Guest
|
Posted:
Thu Jan 20, 2005 6:45 am Post subject:
Search QueryProvider problems |
|
|
I've seen this problem addressed several times in the archives but I
failed to find a solution. I'm hoping someone can shed new light.
the following exception is thrown when trying to instantiate a
QueryProvider object:
Object reference not set to an instance of an object.
at Microsoft.SharePoint.Portal.Search.c.c() at
Microsoft.SharePoint.Portal.Search.c..ctor(String A_0) at
Microsoft.SharePoint.Portal.Search.d.e(String A_0) at
Microsoft.SharePoint.Portal.Search.QueryProvider..ctor(String
strSiteName) at simpleWebPart.WebPart1.createSearch()
Code Snippet:
protected string createSearch() {
String msg = "";
try {
TopologyManager topology = new TopologyManager();
PortalSite portal = topology.PortalSites[new
Uri("http://testServer")];
PortalContext context = PortalApplication.GetContext(portal);
// test msg to show HttpContex object and PortalContex obj are valid
msg += "Context (server name): " + Context.Server.MachineName +
"<br>";
msg += "Search app name: " + context.SearchApplicationName;
QueryProvider qp = new QueryProvider(context.SearchApplicationName);
}
catch (InvalidOperationException ex) {
msg += "<br>" + ex.Source + "<br>" + ex.Message + "<br>";
msg += ex.StackTrace;
}
catch (Exception ex) {
msg += "<br>" + ex.Source + "<br>" + ex.Message + "<br>";
msg += ex.StackTrace;
}
return msg;
}
I am essentially following the procedure outlined in Microsoft's
article
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_sp2003_ta/html/office_sharepointportalserversearchbox.asp
printing out msg shows:
a) the HttpContext object is not null and properties are set to actual
values.
b) the PortalContext ojbect is not null and was properly instantiated
and the SearchApplicationName property contains a guid.
c) the above referenced error message thrown within the QueryProvider
constructor.
I am trying to execute the above code inside a webpart located on a
WebPartPage stored within a document library on a portal top level
site. I have not found any documentation regarding when or where a
QueryProvider object can or cannot be instantiated.
Any insight would be greatly appreciated.
Thanks.
-Abro |
|