I am trying to reorganize an old piece of code that was paved with a loaf together, in a hurry into something more elegant.
There are two parts to the project: a Windows service and a form application that monitors the activities of services.
To allow this connection, I decided to use an unconfigured file with memory.
Below is the working code in the old project:
var security = new MemoryMappedFileSecurity(); security.AddAccessRule(new AccessRule<MemoryMappedFileRights>("everyone", MemoryMappedFileRights.FullControl,AccessControlType.Allow)); file = MemoryMappedFile.CreateOrOpen(@"Global\" + instance, bufferSize, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.DelayAllocatePages, security, HandleInheritability.Inheritable);
The above code is located in ctor, which is launched by both the service and the form, they use the same code and work regardless of what mmf creates.
Now I have the same code in a new project, but if the service first creates mmf, then the form receives a path access error message, and if the form creates mmf, then the Service "opens" its side perfectly, but none of them can see the written information, which makes me believe that they actually do not look at the same thing.
At this point, I donโt know where to start debugging the problem, I use the security rule and the Global namespace because of the session isolation.
I just canโt wrap my head around why it works in one, but not in the other.
Any advice on where to go from here would be appreciated. Also, if more code is required, just let me know.