我有一个由 MSSQL 数据库支持的 GIS 层。例如,图层上的特征有一个 esriFieldTypeString 类型的字段和一个 esriFieldTypeBlob 类型的字段。我可以很好地编辑字符串字段,但是,当我尝试编辑 blob 时,StopEditOperation() 会抛出一个非常通用的异常(消息:“错误 HRESULT E_FAIL 已从对 COM 组件的调用中返回。”,错误代码: -2147467259)。我在服务器日志中找不到任何相关内容。有谁知道发生了什么?
IServerContext serverContext = GetServerContext(agsConn, serviceName);
ILayer layer = GetILayer(layerName, serverContext);
IWorkspace workspace = GetIWorkspace(layer);
var feature = GetIFeature(objectId, workspace, layer);
var workspaceEdit = (IWorkspaceEdit)workspace;
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();
var index = feature.Fields.FindField(featureDetailName);
IField field = feature.Fields.get_Field(index);
byte[] byteArray = {1, 2, 3};
MemoryBlobStream blob = new MemoryBlobStream();
((IMemoryBlobStreamVariant)blob).ImportFromVariant(byteArray);
if (field.CheckValue(blob))
{
feature.set_Value(index, blob);
}
feature.Store();
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
serverContext.RemoveAll();
serverContext.ReleaseContext();