Our application runs on WinCE5.0 (written in .net cf)
Because of certain reasons we had to create MMF file for use by our application (the MMF file should be used by our application only).
Now what we noticed that at random times (we are not able to find exactly when and under what circumstances) the MMF file is used by some other process, which writes the data on it. This makes our MMF file corrupt.
Please let us know how to avoid this.
In other words, we want to have the MMF exclusively for our application and not shared across.
Thanks.
Memory-mapped files on Windows CE are always mapped in a shared file-mapping area of the virtual address space. All processes have read-write access to this area. You cannot protect this area from being overwritten by another process.
The .NET Compact Framework itself uses memory mapping to map loaded assemblies in that area, to avoid loading them in the process slot. I would expect that you would have other problems occurring, such as getting
TypeLoadException
,MissingMethodException
, orExecutionEngineException
when .NETCF tries to JIT code from an assembly that's been corrupted.Are you sure that you are not closing the file mapping handle, or the underlying file handle? That could cause Windows to think that the memory is free, and reuse it for other purposes.