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.

Right-click the Project, select Properties, and on the Properties canvas, click the build tab. Change the platform target to Any (or x64 if you prefer).

Advertisements

15 responses to “SharePoint 2010 Console Application System.IO.FileNotFoundException Error”

  1. Rikard says :

    Thanks for saving me a bunch of time!

  2. Pranav says :

    hi,
    we tried changing traget frameword to 3.5 and changed target cpu to 64x, still we are getting the same error.

    suggest something…

  3. richa says :

    Hello,

    I am getting the same error also use your suggestion but didn’t worked , I am using Sharepoint foundation beta version 2010 and VS2010 beta version.Please help

  4. RC says :

    Hi david,
    I’ve followed your instructions but I am still having the FileNotFound error. Any idea?

  5. RC says :

    I’ve done that as well and the dll looks fine.

    Since I need to target the .NET framework 3.5 what I want to try is to install VC 2008 and build a new project from there. What do you think??

  6. RC says :

    I meant VS (Visual Studio) 2008.

  7. RC says :

    It works Now!!!

    Thanks very much for your assistance!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: