[Solved] SharePoint System.IO.FileNotFoundException was unhandled

Visual Studio Console Application - SharePoint

Creating a Visual Studio console application for SharePoint is a good idea if you want to do a small POC (proof of concept). This saves a good amount of time and the overhead of deployment and server reset. We will not focus on creating a console application, but learn how to resolve/fix the most common error that developers face here - "FileNotFoundException was unhandled"

Error - System.IO.FileNotFoundException was unhandled

This error occurs because Visual Studio console applications run on the 32-bit mode by default, but SharePoint (2010 and above) is built on the 64-bit mode.

The error says - System.IO.FileNotFoundException was unhandled.

The error description says - The Web application at http://yoursharepointsite 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.

How to fix ?

To fix the issue simply change the Build platform target to 64-bit (x64).

Step 1 - From the Solution Explorer, right-click on the project and click "Properties", click on "Build" and change the Platform target to x64 (64 bit). Save the changes.

Step 2 - Re-run your application and this time it will run as expected with any issues.


This is not an AI-generated article but is demonstrated by a human.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!