While writing my first console application to communicate with SharePoint 2010, I was surprised to receive a FileNotFoundException during the creation of a new SPSite.
The line
returned the error statement:
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.
At first I assumed that the error was caused by invalid user rights, but after some searching this forum post at Microsoft Technet came up with the right solution.
By default the console project is build for the .Net 4 framework and and the x86 platform. Because SharePoint is only available as a 64bit version, the console app should also be compiled for the 64bit platform.
By changing the framework to .Net 3.5 and the target platform to x64 the issue was resolved.
March 25, 2010 at 8:07 am
This problem also occurs when you try to communicate with the farm; SPFarm.Local will be null when the platform target isn’t x64.
Also, when using MSBuild and AnyCPU made build tasks against SharePoint x64 (2007+) make really sure that you use the x64 version of MSBuild in the Framework64 folder else you’ll encounter some of the same problems (Visual Studio command prompt uses the x32 version by default, even on a x64 platform which i didn’t notice until i logged the contents of the $MSBuildBinPath property to the screen…)
March 25, 2010 at 3:08 pm
@Cyriel, thanks for sharing the additional information!
July 16, 2010 at 2:24 pm
Was googling around, until I ran into this post. That’s the exact information I needed!
Thanks for posting 🙂
December 10, 2010 at 11:39 am
Thanks, solved my problem, saved me some time.
December 31, 2010 at 10:42 pm
This error can also happen if the in user does not have permission to login to config db.. I ran in to this and have doc’ed it here:
http://buddhian.blogspot.com/2010/12/filenotfound-exception-while-creating.html
February 8, 2011 at 12:00 pm
I am getting same error from my ASP.NET application. What all changes I have to do, to resolve it.
February 9, 2011 at 5:04 pm
Muchas gracias, soluciono mi problema.
Saludos
July 20, 2011 at 10:20 pm
Very useful… I stuggled around 2 hours and this helped me….
August 10, 2011 at 9:29 am
i already try change to 64x n .Net 3.5 Framework, but when i run the web project its fail
August 10, 2011 at 9:30 am
i use visual std.2010, and SP 2010
September 23, 2011 at 12:42 pm
Thanks. This article will solve my problem after a long time. Agian a big thanks to you.
September 25, 2011 at 1:47 pm
You rock!
November 4, 2011 at 10:19 am
The Web application at http://devsrv.com 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.
November 16, 2011 at 10:58 am
true religion jeans outlet where you can buy discount true religion jeans online with worldwide free shipping
December 19, 2011 at 10:10 pm
Thanks buddy.. 🙂
You really saved so much time ..
January 6, 2012 at 7:19 am
Thanks a ton buddy!!! It works like charm. 🙂