Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Access a MemoryMappedFile with Xamarin.Forms

$
0
0

Hi!

I want to use Xamarin.Forms as a Crossplattform UWP and MacOs app. I already got an existing service for the backend.
One major feature i need is a memorymappedfile! (for inter process communication)

so i tryed to create one in a Xamarin.Forms Projekt - but the .net backend-service could not find this memorymappedfile (first question why? - cause of sandbox?)

after that i tryed to created the MemorymappedFile in the .net backend-service:

var CustomSecurity = new MemoryMappedFileSecurity();
CustomSecurity.AddAccessRule(new System.Security.AccessControl.AccessRule<MemoryMappedFileRights>("Everyone",MemoryMappedFileRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
using (var memoryMappedFile = MemoryMappedFile.CreateNew("test", 102400,MemoryMappedFileAccess.ReadWriteExecute,MemoryMappedFileOptions.None, CustomSecurity,System.IO.HandleInheritability.None))
 {
 var accessor = memoryMappedFile.CreateViewAccessor();
 accessor.Write(0, 42);
}

Now Xamarin can find the MemoryMappedFile "test" but i run into an UnauthorizedAccessException:

var memoryMappedFile = MemoryMappedFile.OpenExisting("test");
var accessor = memoryMappedFile3.CreateViewAccessor();

but an other none Xamarin.Forms Project (wpf projekt) can Access this memorymappedfile with the same Code!

I hope some one can help me or tell me how to use a MemoryMappedFile with Xamarin.
My Xamarin App use Xamarin.Forms with .net Standard 1.4 and i installed NuggetPackage: System.IO.MemoryMappedFile to get Access to MemoryMappedFile Basics (without MemoryMappedFileSecurity() )
Thanks a lot!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>