Friday, November 2, 2012

The Web Application Could Not Found

Scenario: I wrote very much simple code as shown below in Web application on button click.

(SPSite site = new Microsoft.SharePoint.SPSite("http://yadnesh-pc/sites/MyTestBed/"))
using (SPWeb web = site.OpenWeb())
// get wikipagelibrary and file
SPListCollection listCollection = web.Lists;
SPList WikiList = listCollection["WkiPageLibrary"];
SPFile Wikifile = WikiList.Items[0].File;

but when I debugged the code I was getting following error at (SPSite site = new Microsoft.SharePoint.SPSite(
http://yadnesh-pc/sites/MyTestBed/)) this line.The Web application at http://yadnesh-pc/sites/MyTestBed/ 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.
I write the code in console application i was getting the same error after doing some Google, I changed project properties as follow
Right click on project-> properties -> build -> platform target -> set it to "any CPU" or "x64".
then error gone.
But same I did for web application but no luck....

No comments:

Post a Comment