I am currently building a WCF service that has some Sharepoint code in it. The service uses wsHttpBinding. The service is hosted in Windows Server 2003 running IIS 6 with integrated windows authentication mode.
It was really strange to me when the service threw this (really a weird) exception:
The Web application at http://localhost/ 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
The code which was throwing this exception was none other than:
Searching the web led me here
The solution was to set the the WCF Service’s application pool’s Identity to the same account Sharepoint website’s application pool uses. Do not try to set the application pool to the same of Sharepoint as it might bring down the Sharepoint website when something goes wrong with the service!
How to verify this?
Good question 🙂
If you open up your WCF client configuration file, look for the <identity> tag inside the Endpoint configuration
You can see that the identity is set to an account in the domain. Verify that with your application pool in IIS
If they both look the same, your Sharepoint code in the web service should work 🙂