使用SPSite构造函数的FileNotFoundException [英] FileNotFoundException with the SPSite constructor

查看:55
本文介绍了使用SPSite构造函数的FileNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在自定义进程(MyApp.exe)中实例化服务器场服务器上 SPSite 的实例,并将整个URI(

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.

但是,无论如何,我都无法创建 SPSite 的实例.它总是抛出 FileNotFoundException .

However, I can't make an instance of SPSite whatever I am trying to do. It always throws a FileNotFoundException.

有人知道吗?

StackTrace:

StackTrace:

在Microsoft.SharePoint.SPSite..ctor(SPFarm场,Uri requestUri,布尔contextSite,SPUserToken userToken)
在Microsoft.SharePoint.SPSite..ctor(字符串requestUrl)MyCompanyName.Service.HelperClass.GetItemStateInSharePoint(SharePointItem项目)中C:\ Workspaces \ MyCompanyName \ Development \ Main \ MyCompanyName.SharePoint \ Service \ HelperClass.cs:line555

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应用程序+网站集,可以毫无问题地通过浏览器进行访问.

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

推荐答案

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

The FileNotFoundException is thrown by SharePoint when it cannot find the requested site collection in the SharePoint configuration database. My guess is that you have not yet created a site collection on the URL http://mysite:80. I see the following stack trace if I try and instantiate a new SPSite object with the URL of a non-existing site collection:

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或打开管理中心并创建一个新的网站集.

Specify the proper URL of your site collection or open Central Administration and create a new Site Collection.

这篇关于使用SPSite构造函数的FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆