I enjoyed using SevenZipSharp until I started compressing multiple streams in different threads at the same time. I seems like concurrent compression is an issue.
The line c.CompressStream(new MemoryStream(raw), o); ist throwing an RaceOnRCWCleanup exception.
I'm using german Visual Studio, so the Exception is in german, too:
RaceOnRCWCleanup wurde erkannt.
Message: Es wurde versucht, einen RCW freizugeben, der derzeit benutzt wird. Der RCW wird im aktiven Thread oder einem anderen Thread verwendet. Der Versuch, einen RCW freizugeben, der gerade verwendet wird, kann Datenbeschädigung oder -verlust zur Folge haben.
My code:
protected byte[] Compress(byte[] raw) {
        SevenZipCompressor c = new SevenZipCompressor();
        c.CompressionLevel = CompressionLevel.Fast;
        c.CompressionMethod = CompressionMethod.Lzma2;
        MemoryStream o = new MemoryStream();
        c.CompressStream(new MemoryStream(raw), o);
        return o.ToArray();
Anyone having a clue how to fix that?


scottlerch wrote Apr 17, 2012 at 5:46 PM

This project has been abandoned by the owner since the last commit was well over a year ago. There are a few patches to the various multi-threading issues including my own here: http://sevenzipsharp.codeplex.com/SourceControl/list/patches. So your best bet is to grab the latest source, apply my patch and build your own copy of the library.

wrote Feb 22, 2013 at 1:16 AM