views:

287

answers:

0

I am trying to use Keyword Query object in asp.net application.

I wrote this code :

Namespace : using System.Data.SqlClient; using Microsoft.SharePoint; using Microsoft.SharePoint.Search; using Microsoft.SharePoint.Search.Query;

Page load event: GridView grd = new GridView(); DataTable dt = new DataTable(); KeywordQuery qRequest = new KeywordQuery("http://server/ril"); qRequest.QueryText = "RILLIB"; ResultTableCollection resTableCollect = qRequest.Execute(); ResultTable resTable = resTableCollect[ResultType.RelevantResults]; DataTable dtTable = new DataTable(); dtTable.Load(resTable, LoadOption.OverwriteChanges); grd.DataSource = dtTable; grd.DataBind();

Page.Controls.Add(grd);

Ok? Whe i run it gives me error : Exception from HRESULT: 0xC0041228

When i saw Logs i found these lines. What the error exactly ? how can i remove that?

Event Type: Error Event Source: Office SharePoint Server Event Category: Office Server Shared Services Event ID: 6481 Date: 05/11/2009 Time: 6:12:25 PM User: N/A Computer: SERVER Description: Application Server job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (41fdea47-166f-4d9f-9cd0-4f3dd0f5cd5b).

Reason: Access to the path 'C:\WINDOWS\system32\drivers\etc\HOSTS' is denied.

Techinal Support Details: System.UnauthorizedAccessException: Access to the path 'C:\WINDOWS\system32\drivers\etc\HOSTS' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamWriter.CreateFile(String path, Boolean append) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) at System.IO.StreamWriter..ctor(String path, Boolean append) at System.IO.FileInfo.CreateText() at Microsoft.Search.Administration.Security.HOSTSFile.CleanupDedicatedGathering(Hashtable HOSTSFileMappings, StringBuilder HOSTSComments, IEnumerable obsoleteHosts, String dedicatedName, Boolean isDirty) at Microsoft.Search.Administration.Security.HOSTSFile.ConfigureDedicatedGathering(SearchServiceInstance searchServiceInstance, SPServer dedicatedWebFrontEndServer, IList`1 previousWebApplicationHostNames) at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.SynchronizeDefaultContentSource(IDictionary applications) at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize() at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.