Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:30:59+00:00 2026-05-22T17:30:59+00:00

How can I share the data between two managed processes using shared memory segments?

  • 0

How can I share the data between two managed processes using shared memory segments? I am using "object" inside C++/CLI code to share the data with some other part of memory in the other process. I am using following code segment.

#define BUFFER_SIZE 32768   

#pragma data_seg (".SHAREDMEMORY")
    bool _Locked = false;
    bool _Initialized = false;  
    unsigned char[10000] data = NULL;
#pragma data_seg() 

#pragma comment(linker,"/SECTION:.SHAREDMEMORY,RWS")

but I need it to be:

#pragma data_seg (".SHAREDMEMORY")
    bool _Locked = false;
    bool _Initialized = false;  
    object^ _object = nullptr;
#pragma data_seg() 

#pragma comment(linker,"/SECTION:.SHAREDMEMORY,RWS")

It is saying that "global or static variable may not have managed type System::Int32^" and giving other errors like "missing ; before '^'".

I have to copy the .NET "Control" object’s data to this shared segment and I need it to transfer to another process.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:30:59+00:00Added an answer on May 22, 2026 at 5:30 pm

    You cannot put .NET objects in shared memory.

    Pointers are only valid in the process they are created in. So data can only be shared if it has no pointers (or uses based addressing, a concept which is mostly dead in the 32-bit flat memory model).

    Sometimes you can get away with C++ objects that have a v-table, as long as the library loads at its preferred base address in all processes. But .NET functions have dynamic addresses because they are compiled at runtime. There’s no hope that metadata pointers will match between different processes.

    Also, how would garbage collection work? Garbage collection needs to see all references to know whether an object is reachable, but you wouldn’t be able to see into the non-shared area of other processes. And to which heap would the memory be returned?

    Conclusion: You can’t put .NET objects in shared segments, shared memory mapped files, or use bitwise serialization. Instead you need to put plain old data in the shared area, and use raw native pointers (not even C++ smart pointers, see above comments about memory management). You can wrap that pointer in a C++/CLI object in order to make it friendly, but you can’t share the .NET object itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a mechanism for interchanging data between two or more processes using shared
Im just trying to share an integer between two processes, but the memory segment
i want to share text data between two iphone apps . How can i
If I make two iPhone applications, how can/should I share custom data (not contacts
I know that I can share files using Shared Folders in Virtual PC, but
I want to share array data between two applications. In my mind, first program
Is it possible to share a core data store between two different iPhone apps
Possible Duplicate: VS2008 Setup Project: Shared (By All Users) Application Data Files? Please can
Can someone share a simple example of using the foreach keyword with custom objects?
Can anyone share an efficient code snipper to daemonize a process in python?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.