FileNotFoundException while developing an external SharePoint application

If you develop a SharePoint Application with Visual Studio 2010, e.g. a Console Aplication, you may get an FileNotFoundException.

For example in this code (program.cs):

namespace DemoConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
           SPSite site = new SPSite("http://sharepoint.local");  //<<--- FileNotFoundException
           SPWeb web = site.RootWeb;
           //your code here

        }
    }
}

I’ve maked the line of code where you may receive the exception.

I solved the problem by setting the platform target in the project settings: Go to “project settings”, select “Build” tab, set “Platform target” setting to the architecture of your platform. I always use “x64” there. – After that the exception is gone.

2 thoughts on “FileNotFoundException while developing an external SharePoint application

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.