This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

I got this error when I use Visual Studio 2010 to program some SharePoint 2010 stuff. It is a simple console program. This exception happens at the following line:

SPWebApplication webApplication = SPWebApplication.Lookup(new Uri("http://mysiteurl"));

Below is another error:

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

and this happens at line

SPSite site = new SPSite("http://mysiteurl");

Both of the errors have the same root cause.


Right Click your project, Choose Properties. Go to tab “Build”, Change Platform Target from “x86” to “Any CPU”. Recompile your project and you will be all set to go.


Leave a Reply

Your email address will not be published. Required fields are marked *