SharePoint 2010 Console Application System.IO.FileNotFoundException Error
I created a new console application to test some code snippets for SharePoint 2010 in Visual Studio 2010.
It threw the following error:
System.IO.FileNotFoundException was unhandled
Message=The Web application at http://demo/ 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.
What a striking error! FileNotFound?
The issue is that, as we already know, SharePoint 2010 only runs in x64 bit and thus we only have 64-bit code on our machine. The default console application template in Visual Studio has a default of x86. If we change our Build platform target, we’ll get past this FileNotFound error.