dll - Attempted to read or write protected memory. This is often an indication that other memory is corrupt in c# (Access violation) -


[unmanagedfunctionpointer(callingconvention.cdecl)] public delegate int decompressmcx(object hcomp,ref byte[] @in, uint @in_len, ref byte[] @out, ref uint out_len, bool eod);  public class xceedcompressor {      [dllimport("kernel32.dll")]     public static extern intptr loadlibrary(string dlltoload);      [dllimport("kernel32.dll")]     public static extern intptr getprocaddress(intptr hmodule, string procedurename);             byte[] outrec = new byte[1024 * 100];     uint outlen;     decompressmcx decompressdelegate;     int b ;     unsafe int l;      public xceedcompressor()     {         intptr pdll = loadlibrary(@"xceedzip.dll");         intptr paddressoffunctiontocall = getprocaddress(pdll, "xcuncompress");         decompressdelegate = (decompressmcx)marshal.getdelegateforfunctionpointer(paddressoffunctiontocall, typeof(decompressmcx));     }      public byte[] decompress(byte[] inrecarr)     {         outlen = 0;         l = decompressdelegate(b, ref inrecarr, (uint)inrecarr.length, ref outrec, ref outlen, true);         return outrec;     } } 

this class want perform decompression.

xceedcompressor xcd = new xceedcompressor (); xcd.decompress(some data compressed same library); 

but giving error "attempted read or write protected memory. indication other memory corrupt."

http://doc.xceedsoft.com/products/xceedzip/uncompress_method.html

is function want pinvoke. hope best solution, find here. in advance.

any reason why not using xceed's csharp lib or alternative zip library?
should define delegate as

public delegate int decompressmcx(int hcomp,intptr in, uint in_len, intptr out, ref uint out_len, bool eod);

when generating in intprt, important fix is, garbage collector not move in data while compression running.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -