kwizcom banner advertisement

FileNotFoundException on new SPSite Call in SharePoint 2010

Today, I tried writing a console application to fetch some data from SharePoint for a 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("http://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 an another situation, this happened due to in-sufficient permissions (password expired).
FileNotFoundException on new SPSite Call in SharePoint 2010 FileNotFoundException on new SPSite Call in SharePoint 2010 Reviewed by Salaudeen Rajack on 1:38 PM Rating: 5

1 comment:

Please Login and comment to get your questions answered!

Powered by Blogger.