Search code examples
c#memoryconfigurationmemory-mapped-files

Storing .NET object to memory and leaving it there after exit


I was wondering if there was a way to load an object in memory and leave it there after the program exist. I want to do this to share configuration info across a WCF REST service without having to go to the disk for serialization/deserialization every time the config is read. An issue I am having is there is no guarantee that something is always running to "hold" the object.

I am using C# and .NET 4.0.

Here is some psuedo code that models what I will/hope to do:

variable localmemoryobject
if memoryObject does not exist then
    create the memory object
end if 
copy the memory object into localmemoryobject
done

I am looking into memory-mapped files to accomplish this and wasn't sure if this was appropriate for my issue. Any suggestions?


Solution

  • How about adding a Windows service app for your configuration and keep that alive?