Wednesday, 29 April 2009

System.IO.FileNotFoundException: The Web application at http://xxxxx could not be found. Verify that you have typed the URL correctly

Have you have this problem? probably because you try to call the object SPSite from a webservice. I assume you get this error:

System.IO.FileNotFoundException: The Web application at http://panshare-cl01 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 Service.WebServiceDescription() in c:\Inetpub\wwwroot\SiteManager\App_Code\Service.cs:line 57

It is quite scary...but there is a easy way to fix it.

Basically if you doing this call SPSite mySite = new SPSite(http://panshare-cl01/);
Your webservice that in this case is located in he port 88, in a different pool it will fail because it doesn't have the authentification for SQL Server and as any sharepoint developer knows Sharepoint is a bunch of websites kept in Sql Server, and if this one doesn't run properly Sharepoint becomes useless.

Anyway, the issue is a satabase security problem so in order to solve it, just do the following;

1- Go to IIS
2- Web Sites
3- Default Web Site
4- If the webservice is located to the webservice ,ie: SiteManager
5- Right click->Properties
6- Change the "Application pool" from "DefaultAppPool" to "Sharepoint - 80"

Have a look:

No comments: