Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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;

        try
        {
            // 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.SaveToFile(fullPath);
            pMemStream = null;

        }
        catch (Exception ex)
        {
            return;
        }
    }

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#?

share|improve this question
    
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 –  JuniperAsh May 8 '13 at 17:55

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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. –  JuniperAsh May 9 '13 at 2:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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