我想寻求帮助。我需要编写远程连接到 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 服务并将任何数据加载到元数据存储中,如果可以,我该怎么做。