FileNotFoundException with the SPSite constructor

2019-04-18 01:42发布

I try to instantiate an instance of SPSite on the farm server in a custom process (MyApp.exe) and I give it as parameter the whole URI (http://mysite:80/). 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. It always throws a FileNotFoundException.

Anyone got an idea?

StackTrace:

at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at MyCompanyName.Service.HelperClass.GetItemStateInSharePoint(SharePointItem item) in C:\Workspaces\MyCompanyName\Development\Main\MyCompanyName.SharePoint\Service\HelperClass.cs:line 555

Another side note... I have a Web Application + Site collection that I can access through the browser without any problem.

21条回答
劳资没心,怎么记你
2楼-- · 2019-04-18 02:24

This Issue is more of user permission issue give the following permission

User Permission SharePoint Site --- Minimum Read Permission

Sharepoint Server --- Add to WSS_ADMIN_WPG group

Database --- Sharepoint Content DB (Site collection database) - db_owner permission Sharepoint Config DB (Config DB of sharepoint installation) - - db_owner permission

Read more in my blog

http://sharepointinstallation.blogspot.com/2010/12/minimal-permission-required-to-execute.html

查看更多
【Aperson】
3楼-- · 2019-04-18 02:29

Same problem on SharePoint 2010. However the issue was with our web service which was accessing the SharePoint object model. The app pool that this service should run under should be a farm admin.

查看更多
再贱就再见
4楼-- · 2019-04-18 02:32

I was plagued by this a few weeks ago. Ultimately I discovered that the file that could not be found was the SharePoint assembly itself. The runtime was failing to load the satellite assembly via late-binding.

The solution to my problem was to register the SharePoint 12.0.0.0 Assemblies in the GAC. It doesn't sound like it's the same as your problem, but just FYI.

查看更多
登录 后发表回答