When developing against the SharePoint object model in an application outside of IIS (service, console, Winforms etc..) you receive the error “FileNotFoundException” when creating an instance of the SPSite object.
ERROR MESSAGE:
System.IO.FileNotFoundException: The Web application at http://
If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.\n
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)\n at Microsoft.SharePoint.SPSite..ctor(String requestUrl)\n
SOLUTION:
The user running the application needs to have the following permissions and group membership set:
· The user is a server farm administrator.
· The user has Read and Write permissions on the content database.
· The user is a site collection administrator.
· The user has permissions to access the Windows SharePoint Services site or the SharePoint Server 2007 site through which the code iterates.
REFERENCE LINK:
http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/5834679b-482b-4924-b881-fa2146840d05/