[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 good amount of time and the overhead of deployment and server reset. We will not focus on creating console application, but learn how to resolve/fix the most common error which 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 ?

In order 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.




Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.