BinaryFormatter Problems
Hi there. I'm not used to asking for help because I normally work it all out for myself but I'm temporarily stuck and before I decide to go down a different route, I thought I'd ask if anyone's got any ideas. Part of my project involves an in-memory catalogue. It used to be quite small (when binary serialized only 2MB), but due to some bugs, we've (at least temporarily) increased its size because re-using some of the objects produced undesirable results. The problem is this. Because of its size, persisting to the database in the usual ways stopped being viable because the object had to be serialized to a byte array (which is now massive - don't know how big yet because it is still writing). So I hunted around and found a BlobStream object that I tweaked for my usage. While pausing the debugger to check its progress I discovered that the binary formatter writes one byte at a time. Although generally sensible, it isn't really desirable for me - I'd rather write in much larger blocks - possibly 0.5 meg at a time. There appears to be no way of increasing the block size of the formatter - it's creating a one-element array for every byte and so calling the Write method millions of times. I could use Reflector, see how it all works and write my own but it seems like overkill for this purpose. Does anyone know if there is a way to change how the binaryformatter writes to a stream OR if there is a class already out there that will allow me to do this? Thanks very much
|