Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileNotFound Exception with Sharepoint 2010 with the SPSite Constructor

I try to instantiate a instance of SPSite on the farm server in a console app and I give in parameter the whole website (http://sp2010/). I also made sure that the account running MyApp.exe is Site Collection Administrator.

However, I can't make an instance of SPSite whatever I am trying to do. I always gives back "FileNotFoundException".

Anyone got an idea?

StackTrace:

System.IO.FileNotFoundException: The Web application at http://localhost/sandbox could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application. at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken) at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at Conchango.xyzzy.GetExistingDocument(String minId, String maxId, String titleFilter) in C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\Projects\xyzzy\BDC_DocReview\BDC_DocReview\DocReviewFacade.asmx.cs:line 69

When i run this app using the App Pool Identity account it works fine. However when I run this console app using a different user that is a Site Collection Admin, Farm Admin, has dbowner rights on the content database for the Sharepoint Web application.. it does not work right and gives me this Filenot Founf Exception.

The Console app uses .Net Framework 3.5 and x64 as the CPU platform. Again this works if i use the App Pool Identity Account, but not with any other account

like image 854
Rohit Gupta Avatar asked Sep 23 '10 02:09

Rohit Gupta


2 Answers

User running the console application needs to have at least read permission to the SharePoint databases, otherwise you will see this kind of errors

like image 117
Vladi Gubler Avatar answered Oct 17 '22 09:10

Vladi Gubler


I had this problem and solved it for my console application by changing the "Platform target:" option on the "Build" properties page to "Any CPU".

like image 35
John Holliday Avatar answered Oct 17 '22 11:10

John Holliday