shared memory - Sharing non-serializable control objects between running applications in C# -


is there way share non-serializable control object between 2 different applications.

i've used below code sharing data among 2 applications, working fine. problem need share non-serializable objects between these applications.

application one

using (memorymappedfile mmf = memorymappedfile.createnew("testmap", 10000)) {     bool mutexcreated;     mutex mutex = new mutex(true, "testmapmutex", out mutexcreated);     using (memorymappedviewstream stream = mmf.createviewstream())     {         binarywriter writer = new binarywriter(stream);         writer.write(1);     }     mutex.releasemutex();      string path = @"second application's path";      //run second application     process pr = new process();     processstartinfo prs = new processstartinfo();     prs.filename = path;     pr.startinfo = prs;     bool ret = pr.start();      mutex.waitone();     using (memorymappedviewstream stream = mmf.createviewstream())     {         binaryreader reader = new binaryreader(stream);         messagebox.show(string.format("process says: {0}", reader.readboolean()));         messagebox.show(string.format("process b says: {0}", reader.readboolean()));     }     mutex.releasemutex(); } 

applicatin second

try {     using (memorymappedfile mmf = memorymappedfile.openexisting("testmap"))     {          mutex mutex = mutex.openexisting("testmapmutex");         mutex.waitone();          using (memorymappedviewstream stream = mmf.createviewstream(1, 0))         {             binarywriter writer = new binarywriter(stream);             writer.write(0);         }         mutex.releasemutex();     } } catch (filenotfoundexception) {     messagebox.show("memory-mapped file not exist. run process first."); } 

can 1 me solution.

to knowledge, memory mapped files cannot directly contain live managed objects. there 2 ways use memory mapped files: using memorymappedviewstream (which our example doing), or using memorymappedviewaccessor. latter lets treat big buffer of memory, reading , writing calls readdouble(offset) , write(offset, doublevalue). there accessor methods reading , writing arrays.


Comments