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.

Advertisements

One thought on “FileNotFoundException while developing an external SharePoint application

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