AnsweredAssumed Answered

GeodatabaseFeatureTable.AddAttachmentAsync() Is Failing if Attachments Not Synced

Question asked by jsiemens on Dec 2, 2015
Latest reply on Jan 20, 2016 by arned

I'm getting a null reference exception on GeodatabaseFeatureTable.AddAttachmentAsync().


Here's a code snippet.


            var table = _gdb.GetFeatureTableById(layerId);

            var feature = (GeodatabaseFeature)await table.QueryAsync(featureId);

            var canAddAttachment = table.CanAddAttachment(feature); // Returns true

            var hasAttachments = table.HasAttachments; // Returns true

            var result = await table.AddAttachmentAsync(featureId, options.Data, options.FileName, options.ContentType); // Null reference exception


The null reference exception is happening inside AddAttachmentAsync(). Interestingly, both CanAddAttachment() and HasAttachments both return true even if the table does not have any attachments synced.


If attachments are included when the geodatabase is generated, then all is well.


But... it seems like users should not be forced to take attachments offline in order to add new attachments. There could be *a lot* of attachment data, and therefore this could really bloat download size and storage space requirements.


In any event, if this is not possible (though it would be nice if it was), a better error message other than a null reference exception would be nice.