Можете ли вы назвать SPSite на другой машине для настройки SharePoint?
-
09-12-2019 - |
Вопрос
Я пытаюсь позвонить SharePoint из строя в стандартной библиотеке классов.Это, вероятно, будет размещено на другом сервере для SharePoint.
Мне просто нужно вернуть элемент из списка и задаваться вопросом, нужно ли использовать клиентскую структуру или если что-то вроде ниже будет работать:
using (SPSite site = new SPSite("http://sitecollection"))
{
using (SPWeb web = site.RootWeb)
{
SPList list = web.Lists["Image List"];
// Get item by name field value
}
}
.
Я в настоящее время просто ссылаюсь на Microsoft.sharePoint.dll
Решение
No, this is not supported.
You need to use the web services or the Client Side Object Model (CSOM)
Другие советы
You need to use the Client Framework to instantiate an SPSite on another farm.
The reason being, is that when you instantiate SPSite, the server running the code looks into it's own farm configuration to find out what content database to get the data from.
If you're on FarmA and want to instantiate a site collection that exists in FarmB, you will get a FileNotFoundException, because that site collection only exists within a web application that is in FarmB's configuration database.