简体   繁体   中英

Open spweb in windows service

I want to check documents properties in SharePoint library. Please tell me how to open SharePoint website in windows service. I am using following code in windows service, it gives "site not found error".

SPSite spSite = new SPSite("http://xyz/sites/abc");

Detail Error is,

System.IO.FileNotFoundException: The Web application at http://xyz/sites/abc could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
   at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
   at SSP_DL_notify_service.Service1.GetMail(Object sender, ElapsedEventArgs args) in C:\Users\pqr\Documents\Visual Studio 2010\Projects\SSP_DL_notify_service\SSP_DL_notify_service\Service1.cs:line 54

Your code is fine.

Are you sure that http://xyz/sites/abc is a site? Is the URL correct?

If the URL is correct then check if you have required permissions to open it.

EDIT:

Check this thread also: SharePoint error: Web application at xxxx could not be found

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM