This fixed it for me:
MemoryMappedFileSecurity
CustomSecurity = new
MemoryMappedFileSecurity
();
CustomSecurity.AddAccessRule(new
System.Security.AccessControl.AccessRule<MemoryMappedFileRights>("everyone",
MemoryMappedFileRights.FullControl,
System.Security.AccessControl.AccessControlType
.Allow));
_mmf =
MemoryMappedFile.CreateOrOpen("Global\\SomeMap",
1024, MemoryMappedFileAccess.ReadWriteExecute,
MemoryMappedFileOptions.None,
CustomSecurity, System.IO.HandleInheritability.Inheritable);
There are no examples of how to use
MemoryMappedFileSecurity that
I can find. The above was 2 hours of searching and trial and error pain!
On a 2008 server R2 64 bit the same CreateOrOpen
code works without throwing exceptions from within a .net service in session 0, admin account in session 1 and normal user account in session 2
-Andy