Is it possible to pass an instance of a “pointer” to another process through a memory-mapped file?

I'm basically looking for a way to pass instances through programs / processes without serializing instances in .NET 4.0.

Yes, I missed my good 100% insecure pointers;)

I thought that the new memory file integration in .NET 4.0 would help me by reading somewhere that you could use references / pointers "natively" using it.

However, when I try something like

var mmf = MemoryMappedFile.CreateFromFile(@"C:\temp\test.mp", FileMode.Create, "mmf",
                                          1024*1024*300, 
                                          MemoryMappedFileAccess.ReadWrite);
var ss = new SimpleStruct();
ss.items = _items; //Collection of Items objects
var FileMapView = mmf.CreateViewAccessor();
FileMapView.Write<SimpleStruct>(0, ref ss); //Exception

I get the following ArgumentException:

The specified Type must be a struct containing no references.

Is it possible to transfer links using MMF? If this is not the case, is there any way to pass instances around programs / processes?

+3
1

, . , MMF-. , . , 4 .NET MMF.

.

+3

Source: https://habr.com/ru/post/1736417/


All Articles