5
votes

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

6
I have Visual Studio installed on the Windows 2008 R2 server. Does this have any effect on the app not workingRohit Gupta

6 Answers

4
votes

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

4
votes

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

2
votes

NET framework you used is not matched with SharePoint 2010 Server,for example .NET 4.5 is applied, the exception will be thrown , change to .NET 3.5 , fix your issue.

1
votes

If you are using MSTest, make sure that the Test Runner matches the platform you are using. See this SO post regarding targeting MSTest for your current platform.

0
votes

I had to make my Windows Forms test application .NET 3.5 instead of .NET 4.5.

0
votes

SP 2010 works only on x64 mode. So change your project platform target to x64. If your service is already running in IIS, than make sure that your app pool has the property Enable 32 bit applications set to false.