tags:

views:

648

answers:

2

For certain file operations we use VB6's PropertyBag object to convert various items to a bytearray via the Content property. We then save the bytearray as part of a binary file. Later when we load the file we read back the file, read in the bytearray and reconstitute the item by using the propertybag's readproperty. We use this a lot to store images like the customer logo.

What support does .NET framework have for working with PropertyBags? Othan than writing a COM helper DLL. Are Property Bags a VB6 only construct or they are part of the general OLE/COM automation framework?

What I am hoping for is avoiding writing a VB6 helper DLL and accessing directly (via declares) the needed COM functions. I am not looking to replicate the functionality but rather converting the object stored in the bytearray into their .NET equivalent.

NOTE: I am not interested in implementing the functionality of a property bag in .NET. Only in being able to read the bytes of a saved VB6 Property Bag.

+2  A: 

There is 0 support for PropertyBags in .NET. Serailisation of objects replaces the PropertyBag construct.

So as I see it you have 2 choices.

  1. Byte the bullet and writer the 10 or 20 line Interop dll.
  2. Analyse the contents of the serialised property bag and see if you can decode it and figure out the offsets of the images and streams etc.

I know which one I'd be heading for.

Bigtoe
I was hoping property bags was do with something deep in the OLE engine. But it looks like interop is the way to go. Thanks
RS Conley
+1  A: 

You can check out Edanmo's Load and save pictures to byte arrays sample on his old VB6 sample page. It's very simple and can be used to "serialize" any object that implements IPersistStream interface like ADODB.Recordset for example. VB6's PropertyBag is using IPersistStream for objects and probably implements "custom" VT_Xxx variant-types serialization.

Btw, Edanmo's code snippet allows you to read images stored via copy/paste to an image column of an Access grid.

wqw
That was a great find thanks.
RS Conley