Monthly Archives: August 2011

The Web application at ” could not be found…!!!

Today a friend was trying to build a console application that will retrieve some list data from a SharePoint site. He had created a console application, added needed SharePoint assembly references and wrote down the following code segment to access the Site Collection and then to retrieve the Web site.

static void Main(string[] args)
 {
     try
     {
         string siteURL = "http://mySite/";

         using (SPSite site = new SPSite(siteURL))
         {
             using (SPWeb web = site.OpenWeb())
             {

             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }

The code get compiled without errors, and when try to execute the line for creating a new SPSite from given site url, it throws and exception. The exception is:

The Web application at ‘http://mySite/’ 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.

We both were pulling hair to figure out what is going wrong. Doesn’t seem like anything wrong.

Later figured out the console application build Platform Target was set to x86. So after changing it to x64 it started working fine. Smile