I have converted a VB6 project to C#, and there is one problem I cannot find documentation on. I am saving an IPropertySet to file by using IMemoryBlobStream and IPersistStream, as seen here:

 public void WriteToFile(string fullPath)
        IMemoryBlobStream pMemStream;
        IPersistStream pPersistStream;

            // Open Stream, must use memory stream instead of FileStream
            pMemStream = new MemoryBlobStreamClass();

            // Write PropertySet to Stream
            pPersistStream = (IPersistStream)m_pPropertySet;
            pPersistStream.Save(pMemStream, 1);

            // Save Stream to File
            pMemStream = null;

        catch (Exception ex)

I get an "HRESULT E_FAIL" with error code "-2147467259" on pPersistStream.Save(pMemStream, 1);

This doesn't throw an error if the PropertySet is empty, only if it has properties within.

When the PropertySet is populated, it is populated by Long data types (int64). Using PropertySet.SetProperty(Name, Value)

Any ideas why this would work great in ArcGIS 8/9 and not in 10 with C#?

  • Could you write code inside of adding property to PropertySet? I guess this error is caused by that property object. – Darksanta May 7 '13 at 3:32
  • I added some more detail on the PropertySet object – Logan B. Lehman May 8 '13 at 17:55

This error is caused by byte size of value, not ArcGIS version. VB6 long type is 4 byte (32 bit Integer), and .NET long type is 8 byte (64 bit Integer). However, I'm not sure why Stream class cannot use it. But in any case, .NET int type is same as VB6 long type, so you may use int type instead.

  • it looks like your assumption was right. I instead converted the values to Int32 instead of Int64, and the saving went smooth. This may be something that needs to be addressed with ESRI (as they wrapped IPersistStream), or with Microsoft (the originator of IPersistStream). I am surprised because I have written way larger objects to file this way, and I have had no problem until now. – Logan B. Lehman May 9 '13 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.