Skip to main content
 首页 » 编程设计

.net之使用SPSite构造函数的FileNotFoundException

2025年02月15日18artech

我尝试实例在定制过程(MyApp.exe将)农场服务器上SPSite的一个实例,我把它作为参数整个URI(http://mysite:80/)。我还相信,在运行MyApp.exe帐户是Site Collection Administrator

但是,我不能做什么,我试图做SPSite的一个实例。它总是抛出一个FileNotFoundException

任何人有一个想法?

堆栈跟踪:

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



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

请您参考如下方法:

当在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) 

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