none
How to share common data in memory created by Windows Service with RIA services RRS feed

  • Question

  • Hi All,

    The crux of the question is how to create a shared memory application that is populated by a Windows service, but accessed by another .NET application (in this case a RIA service) through shared memory. I have been all over the net and not found a clearly defined process for accomplishing this functionality. I have found a lot of out dated posts that apparently do not work with Windows Server 2008.

    I have created a large memory mapped file for a Dictionary class, which is accessible by the creating application and is properly persisted. However, I have not been able to figure out how to create the memory mapped file in a Windows service (i.e., long running) and then access the created instance in a RIA service, which may not be long running. The shared memory needs to be accessible by anonymous users via the RIA service. The Windows service is started automatically on the server as part of the boot/initialization process. The memory mapped file code resides in a separate project than can be shared between the Windows/RIA services. I am not sure how best to implement this sharing. E.g., included projects or dll loaded into each of the other two projects.

    Can someone please point me to a good Microsoft or other reference that explains how to accomplish this task? I would like to find a book on this subject, if anyone knows of one.

    Thanks...


    Warren

    Tuesday, July 17, 2012 6:30 PM

Answers

  • I finally figured out that I did not really need to share all of the data simultaneously between the WCF RIA Service, but I did need a way for the RIA service to access data from the long-running Windows service. Also, the Dictionary that I am using is from a third party source that is incompatible with the .NET 4.0 memory mapped file functionality, so I had to rule out mmf. The library generates 4 memory mapped files for each container, instead of 1, which is incompatible with .NET mmf.

    I have documented a solution for this issue at http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/86b471f1-21d7-4dc3-a326-0fef45b903d1 

    Hope the write-up spares others some of the pain that I had to go through...

    Cheers...


    Warren


    • Marked as answer by highdownts Monday, July 23, 2012 6:48 PM
    • Edited by highdownts Thursday, August 2, 2012 7:04 PM update broken link
    Monday, July 23, 2012 6:48 PM

All replies

  • Does the answer in this link help?
    Wednesday, July 18, 2012 8:28 AM
    Answerer
  • The link deals more with security issues. I will be using dedicated servers and I don't think UAC will even be enabled, which is what the other link focused on. I could be wrong about my need, but my issue is more basic. 

    I am looking for more thorough discussions/articles/etc. that explain how to set up this kind of environment, which has a shared persistent object is memory. For example, a RIA service instance is created for each access by a client. The RIA service, while in existence, needs access to this shared memory mapped file as an anonymous user. RIA methods will control the specific read/write access, which is constrained. 

    I am currently creating the initial memory mapped file with a standard Windows service via a singleton class, but I am open to suggestions. I am not sure how to go about setting up this kind of functionality. If I create a singleton class in a separate library that creates the memory mapped file through a Windows service, how do I access the instance of the populated Dictionary from a RIA service? Is there a way of sharing the singleton class between the RIA service and the Windows service through some global mapping?  

    My web searches have not been very fruitful in answering these basic questions.

    Thanks...


    Warren

    • Marked as answer by highdownts Monday, July 23, 2012 6:46 PM
    • Unmarked as answer by highdownts Monday, July 23, 2012 6:46 PM
    Wednesday, July 18, 2012 12:12 PM
  • I finally figured out that I did not really need to share all of the data simultaneously between the WCF RIA Service, but I did need a way for the RIA service to access data from the long-running Windows service. Also, the Dictionary that I am using is from a third party source that is incompatible with the .NET 4.0 memory mapped file functionality, so I had to rule out mmf. The library generates 4 memory mapped files for each container, instead of 1, which is incompatible with .NET mmf.

    I have documented a solution for this issue at http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/86b471f1-21d7-4dc3-a326-0fef45b903d1 

    Hope the write-up spares others some of the pain that I had to go through...

    Cheers...


    Warren


    • Marked as answer by highdownts Monday, July 23, 2012 6:48 PM
    • Edited by highdownts Thursday, August 2, 2012 7:04 PM update broken link
    Monday, July 23, 2012 6:48 PM