views:

263

answers:

2

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

+1  A: 

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

Vladi Gubler
The user is the dbo in the content database for the web app... does it need permissions on any other database?? Logging?
rbg
Read access to the config DB, he needs it to locate the DB where the site collection is stored.
Vladi Gubler
Also pay attention that the console application runs in the correct mode, 64 bit or 32 bit, this is relevant at least for debugging
Vladi Gubler
That error generally occurs when you've compiled your code to 32bit like Vladi suggests.
Zeb
I found a solution to this... the user needs to be db_owner on the content and config databases and also needs to be part of the WSS_Content_Application_Pools SQL role
rbg
A: 

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".

John Holliday