Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to create Shared memory between C# application and VC++ console application

How to create Shared memory between C# application and VC++ console application

Scheduled Pinned Locked Moved C#
csharpc++visual-studioperformancetutorial
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manoharbalu
    wrote on last edited by
    #1

    I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function. Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application. Please advise and suggest the ways of doing this

    Richard DeemingR OriginalGriffO L J 4 Replies Last reply
    0
    • M manoharbalu

      I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function. Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application. Please advise and suggest the ways of doing this

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      The BCL has plenty of support for memory-mapped files: Memory-Mapped Files | Microsoft Docs[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      M 1 Reply Last reply
      0
      • M manoharbalu

        I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function. Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application. Please advise and suggest the ways of doing this

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        I would strongly suggest that you don't: instead redesign to use message based communications via Named Pipes[^] or Sockets C#[^] / Sockets C++[^] It's a much more robust solution that can be a whole load more flexible.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • M manoharbalu

          I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function. Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application. Please advise and suggest the ways of doing this

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Going in circles. [Shared memory - C# Discussion Boards](https://www.codeproject.com/Messages/5813583/Shared-memory)

          It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

          M 1 Reply Last reply
          0
          • L Lost User

            Going in circles. [Shared memory - C# Discussion Boards](https://www.codeproject.com/Messages/5813583/Shared-memory)

            It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

            M Offline
            M Offline
            manoharbalu
            wrote on last edited by
            #5

            But I didnt get a solution. Please provide me some details and hints how to share memory between C# application and VC++ console application

            L 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              The BCL has plenty of support for memory-mapped files: Memory-Mapped Files | Microsoft Docs[^]


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              M Offline
              M Offline
              manoharbalu
              wrote on last edited by
              #6

              This gives details for creating and opening shared memory between 2 C# application processes. Please help me to share memory between 2 applications, one in C# and other VC++ console application to open the share memory created in C# application. Is it possible of doing this? Please advise

              Richard DeemingR 1 Reply Last reply
              0
              • M manoharbalu

                This gives details for creating and opening shared memory between 2 C# application processes. Please help me to share memory between 2 applications, one in C# and other VC++ console application to open the share memory created in C# application. Is it possible of doing this? Please advise

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #7

                The documentation tells you how to create or access memory-mapped files from a C# application. You presumably already know how to create or access memory-mapped files from a C++ application. If not, the Microsoft docs site has details: Memory-Mapped File Information - Win32 apps | Microsoft Docs[^] The file doesn't care which language was used to create the process that's accessing it.


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                1 Reply Last reply
                0
                • M manoharbalu

                  But I didnt get a solution. Please provide me some details and hints how to share memory between C# application and VC++ console application

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  You're stuck on one approach and not open to suggestions.

                  It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                  1 Reply Last reply
                  0
                  • M manoharbalu

                    I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function. Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application. Please advise and suggest the ways of doing this

                    J Offline
                    J Offline
                    jschell
                    wrote on last edited by
                    #9

                    If helps. A memory mapped file is an OS supported option. C++ can use and access a memory mapped file. C# can use and access a memory mapped file. So the solution is 1. Study memory mapped files so you specifically understand how they can be shared between applications. I believe sharing requires a specific set up. 2. Study the api for C++ memory mapped files. 3. Study the api for C# memory mapped files. 4. Design how the memory mapped file will be used. Pay attention to failure scenarios. 5. Use 2 and 4 to implement a solution in the C++ app. 6. Use 3 and 4 to implement a solution in the C# app.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups