[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.



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap