使用SPSite构造函数的FileNotFoundException

Max*_*ler 22 .net security sharepoint sharepoint-2007 sharepoint-2010

我尝试SPSite在自定义进程(MyApp.exe)中实例化服务器场服务器上的实例,并将其作为参数提供给整个URI(http:// mysite:80 /).我还相信,该帐户运行MyApp.exeSite Collection Administrator.

但是,我无法做出SPSite我想要做的任何事情.它总是抛出一个FileNotFoundException.

有人有个主意吗?

堆栈跟踪:

在Microsoft.SharePoint.SPSite..ctor(SPFarm场,Uri requestUri,Boolean contextSite,SPUserToken userToken)
的Microsoft.SharePoint.SPSite..ctor(String requestUrl)在C中的MyCompanyName.Service.HelperClass.GetItemStateInSharePoint(SharePointItem项)中:\Workspaces\MyCompanyName\Development\Main\MyCompanyName.SharePoint\Service\HelperClass.cs:第555行

另一方面说明......我有一个Web应用程序+网站集,我可以通过浏览器访问它没有任何问题.

Lar*_*rup 14

当SharePoint在SharePoint配置数据库中找不到请求的网站集时,将抛出FileNotFoundException.我的猜测是你还没有在URL http:// mysite:80上创建一个网站集.如果我尝试使用不存在的网站集的URL实例化新的SPSite对象,我会看到以下堆栈跟踪:

System.IO.FileNotFoundException : The site http://server/sites/bah could not be found in the Web application SPWebApplication 
Name=SharePoint - 80 Parent=SPWebService.
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
Run Code Online (Sandbox Code Playgroud)

指定网站集的正确URL或打开管理中心并创建新的网站集.

  • 嗯,那么它可能是一个许可问题.尝试使用与应用程序池相同的凭据而不是网站集管理员运行您的应用程序.否则问题也可能是因为您的SharePoint是64位但您的应用程序正在以32位模式运行. (14认同)
  • 我的问题是我在调用64位SharePoint 2010程序集,但是在32位进程中运行.谢谢@ lars-fastrup! (7认同)
  • @iaf:这是一个许可问题.如果您正在向SharePoint运行具有"未知"用户的EXE,则该用户需要是内容DB + Farm Admin +网站集管理员的dbo.就这样.:) (3认同)

Cha*_*hen 12

将构建属性中的平台目标更改为x64在SharePoint 2010上为我解决了此问题.


小智 10

阅读本网站http://community.bamboosolutions.com/forums/t/8179.aspx,如果您正在运行您的OS x64位并使用MSTest(32位)它将失败,使用nunit工作!