I have a GIS layer backed by a MSSQL db. The features on the layer have, say, one field of type esriFieldTypeString and one of type esriFieldTypeBlob. I can edit the string field just fine, but, when I try to edit a blob, StopEditOperation() throws a very generic exception (message: "Error HRESULT E_FAIL has been returned from a call to a COM component.", error code: -2147467259). I couldn't find anything related in the server log. Does anyone have any idea what's going on?
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();