FileNotFoundException on new SPSite Call in SharePoint 2010

Today, I tried writing a console application to fetch some data from SharePoint for report generation. Started with simple code, Ran it, Boom! Error: “FileNotFoundException was unhandled” in spsite constructor!
filenotfoundexception spsite
Verified that the URL is valid and able to access. In fact, my code was quite simple.

SPSite site = new SPSite(“https://sharepoint”);
Console.WriteLine(site.RootWeb.Title);

spsite filenotfoundexception sharepoint

Solution is simple! Go to Project Properties, change the platform target from x86 to x64 or any CPU. Also, make sure the .Net framework is 3.5. Huh! Once again made this silly mistake, Next time I’ll take care.

Similarly, “Web application at URL could not be found” exception while accessing SharePoint site through object model may occur for the above cause!

It could be also because: Account has been locked!  In another situation, this happened due to insufficient permissions (password expired).

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “FileNotFoundException on new SPSite Call in SharePoint 2010

Leave a Reply

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