MemoryMappedFile Issue C#/C++
Posted on 2007-04-05
I have a Memory Mapped File that is being populated by a seperate C++ application and I am reading the contents of that file using a C# Windows Application. Everything works fine from the perspective of opening the file and view, retrieving the data and working with the resultant byte array.
However, I need to zero-out the memory when I am done and I cannot get that to work. When I call the ZeroMemory Kernel Method, I keep getting the following:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Here the DLL Import signature:
[DllImport("kernel32", SetLastError = true)]
public static extern void ZeroMemory(IntPtr dest, int size);
Can somebody please help?