我想寻求帮助。 我需要编写远程连接到Sharepoint服务(BDC服务)的代码,并在BDC元数据存储中执行任何更新。 在msdn中我找到了这个样本:
using (SPSite site = new SPSite("http://ssdk-server/Pages/Default.aspx"))
{
using (new Microsoft.SharePoint.SPServiceContextScope(SPServiceContext.GetContext(site)))
{
BdcService service = SPFarm.Local.Services.GetValue<BdcService>(String.Empty);
IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
IEntity entity = catalog.GetEntity("http://ssdk-server/sdksamples", "Customer");
ILobSystemInstance LobSysteminstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
IView createView = entity.GetCreatorView("Create");
IFieldValueDictionary valueDictionary = createView.GetDefaultValues();
valueDictionary["Name"] = "some name";
Identity id = entity.Create(valueDictionary, LobSysteminstance);
}
}
但是,这引起了第一行的异常:
FileNotFoundException (The Web application at http://sharepoint/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.).
我发现了同样的问题,但提出的解决方案(将项目设置框架更改为3.5,平台更改为x64)对我没有帮助。
任何人都可以这样说,是否有可能远程连接到BDC服务并将任何数据加载到元数据存储中,如果是这样,我该怎么做。
答案 0 :(得分:1)
无法以这种方式连接到远程sharepoint服务器。 您应该使用Client Context
例如:
string siteUrl = "http://MyServer/sites/MySiteCollection";
ClientContext clientContext = new ClientContext(siteUrl);
Web oWebsite = clientContext.Web;
ListCollection collList = oWebsite.Lists;
clientContext.Load(collList);
clientContext.ExecuteQuery();
foreach (SP.List oList in collList)
{
Console.WriteLine("Title: {0} Created: {1}", oList.Title, oList.Created.ToString());
}
您可以找到更多示例here