The official docs doesn't properly state if ipc via memory-mapped-files is supported in uwp. I was working on a scenario for ipc between an uwp app and its desktop extension. While I can create memory-mapped-files using System.IO.MemoryMappedFiles
from uwp app with codeGeneration
capability but opening from win32 process fails with message Unable to find the specified file.
. Is ipc via memory-mapped-files supported in uwp, if yes, what is the proper way to do it??
Minimal reproduceable sample.
Updated sample implementing answer from @Peter Torr - MSFT.
Working sample in which memory-mapped-file created from uwp app can be read by win32 process. Reading memory-mapped-file in uwp app created by win32 process still isn't working.
Yes it is supported, but if you're creating the object in a UWP context and opening it from a Desktop context then the Desktop process needs to explicitly use the namespace of the named object.
From within your UWP process, call GetAppContainerNamedObjectPath(nullptr, nullptr, ...)
to determine what that namespace is, and then add a backslash and your mapped file name to the end. It will be something like AppContainerNamedObjects\S-1-15-2-xxxxxxx\YourMappedName
You should only need to do this once, unless you change your package name (including the publisher hash). So once you have generated it, you can hard-code the value into your desktop app and forget about it.
Note that if you do it the other way around - Desktop creates the object, and UWP opens it - then you don't need to worry about the namespace, but you have to modify the access control instead, which is trickier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With