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 - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world 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 *