justinstenning / SharedMemory

C# shared memory classes for sharing data between processes (Array, Buffer and Circular Buffer)
https://www.nuget.org/packages/SharedMemory
Other
566 stars 118 forks source link

((Unity 3D) FileNotFoundException) MemoryMappedFile not found error #23

Closed karlkoorna closed 7 years ago

karlkoorna commented 7 years ago

Unity version: 5.5.2f1 (free version) SharedMemory version: 2.0.16 (.NET 3.5 version)

Code: https://pastebin.com/qPtWjKPn

Problem: On launch gives an error:

FileNotFoundException: Unable to find the specified file.
System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting (System.String mapName)
SharedMemory.SharedBuffer.Open ()

I don't know if it's a bug or if I'm missing something

Seems to work in this project which seems to have very similar SharedMemory base init code: https://bitbucket.org/vitaly_chashin/simpleunitybrowser/src/ad994940800930c03bafa14ca1f4b159789c4c77/UnityClient/Assets/SimpleWebBrowser/Scripts/BrowserEngine.cs?at=default&fileviewer=file-view-default#BrowserEngine.cs-434

justinstenning commented 7 years ago

You need to use the constructor that specifies the size in order to create the shared memory, otherwise it is just trying to open one that doesn't exist yet.

karlkoorna commented 7 years ago

Thank you!