CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2006
    Posts
    120

    Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    When using MS C++, I can share data between two instances of an application by defining it within a shared data segment viz:

    #pragma data_seg(".sdata")
    int sharedint = 0;
    #pragma data_seg()

    #pragma comment(linker, "/SECTION:.sdata,rws")


    Is there a way of doing this in C#?

    Thanks

    M.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    >> Is there a way of doing this in C#?
    Yeah, however you do shared memory in .NET - which I'm not familiar with. I just want to point the dangers of shared sections in C++.
    http://blogs.msdn.com/oldnewthing/ar...04/208003.aspx

    gg

  3. #3
    Join Date
    Nov 2006
    Posts
    120

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    I am aware of this, but still, any ideas how to do what I want?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    You can create the shared section (or the more secure file mapping) in a dll and pinvoke to it in the .net application.

    Another approach is to have the application host a WCF web service to perform the data transfer.

    With this approach, the first instance of the application would host the WCF service and subsequent instances would simply connect to the service.

  5. #5
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    Quote Originally Posted by Arjay View Post
    Another approach is to have the application host a WCF web service to perform the data transfer.
    Isn't it too heavy solution? What about remoting or named pipes? I think that named pipes is designed exactly for similar scenarios.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    Quote Originally Posted by boudino View Post
    Isn't it too heavy solution?
    I don't think so. Unlike a .Net 2.0 Web service, it's quite simple to host a WCF service inside a .Net application. See http://msdn.microsoft.com/en-us/library/ms731758.aspx for more info.

  7. #7
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    I know, but event in this case, the whole WCF machinery with all dispatchers, channels and all the infrastructure is in the play. It will definitely work, but I still think that if the communication is in-process or in-machime (as I understand the original question), the overhead is too big.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton

    Quote Originally Posted by boudino View Post
    It will definitely work, but I still think that if the communication is in-process or in-machime (as I understand the original question), the overhead is too big.
    Respectfully, please define 'too big'.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured