473,623 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET inter process shared memory

1 New Member
I'm using SendMessage(... ) to send a message to all other process that might run. It works well. My problem is when I try to pass data using shared memory. Here is my code.

In the 1st process, I use this to send the msg

BinaryFormatter b = new BinaryFormatter ();
MemoryStream stream = new MemoryStream();
b.Serialize(str eam, str);
stream.Flush();
int dataSize =(int) stream.Length;
byte[] data = new byte[dataSize];
stream.Seek(0, SeekOrigin.Begi n);
stream.Read(dat a, 0, dataSize);
IntPtr ptrData = Marshal.AllocHG lobal(dataSize) ;

Marshal.Copy(da ta, 0, ptrData, dataSize);


SendMessage(0xf fff, lMsg, ptrData, Convert.ToInt64 (dataSize));


In the other process i use this


protected override void WndProc(ref Message m)
{
base.WndProc(re f m);

if ((UInt32)m.Msg == theCloseMsgId)
{
int bufferLenght = m.LParam.ToInt3 2();
byte[] data = new byte[bufferLenght];
Marshal.Copy(m. WParam, data, 0, bufferLenght);

BinaryFormatter b = new BinaryFormatter ();
MemoryStream stream = new MemoryStream();
stream.Write(da ta, 0, data.Length);
stream.Seek(0, SeekOrigin.Begi n);
string str = (string)b.Deser ialize(stream, null);
forceClose = true;
Close();

}
} //WndProc

I tried this in the same process and it works but in two differents process, the shared memory that was allocated with Marshal.AllocHG lobal() has changed. Anyone can help me ? Maybe another way to create the memory ?
Mar 18 '08 #1
0 1304

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1278
by: Steve T | last post by:
Hi, I am developing some software in C++ to access a PMC card in a PC. The PMC card comes with a set of C++ libs to access it and to handle interrupts from it. I am therefore writing entirely in C++ at the application level and have no access to the device driver for the PMC. My design involves: - a single process running on the host machine to handle all DMAs from the PMC to the host.
4
4956
by: Viper Venom | last post by:
Dear All: I am trying to write an application that consist 2 executables 1) Server.exe 2) Client.exe I start the server.exe first and then start the two client exe by code and kill both of the client when the server exit (This is already done)
7
31695
by: A.M | last post by:
Hi, What is the best way to implemet Inter Process Communication in .NET ? I developed two programs and I want to have them talk to each other. Thanks, Alan
4
1193
by: Paul Baker | last post by:
Hello All, This is my first post so apologies if this is the wrong newsgroup. I'm designing software for a platform that will sit on a CAN bus. There will be three separate programs running on the platform, A, B and C. Program A will handle the CAN communications. It will pass messages received from the CAN network to programs B and C and transmit their messages out on the CAN network.
35
5489
by: Alex Martelli | last post by:
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is indeed fixed. Being in a hurry, I originally used a q&d hack...: if sys.platform in ('linux2', 'darwin'): def _memsize(): """ this function tries to return a measurement of how much memory this process is consuming, in some arbitrary unit...
1
2143
by: Michael L | last post by:
Dear all, I have an ActiveX control that is hosted by a C# webbrowser control. The activex is written in C++ and I need a way to communicate between the activex and other c# applications or c++ applications for multithreading. Can someone give me some hints? Thanks in advance, Michael L
8
4039
by: =?ISO-8859-15?B?TnXxbw==?= I.G | last post by:
Hello to everybody: I'm trying to get some information about "process management". Let's explain a little... I want to write some code that allows me to execute some "aplications" and collect the data they produced. This apllicationis a kind of "client" that must work in more that one SO (for example *NIX, Windows98, Win2000). So my question is about what kind of "managemet" of this proccess I can do, and how to start and "monitor"...
28
4928
by: Jon Davis | last post by:
We're looking at running a memory-intensive process for a web site as a Windows service in isolation of IIS because IIS refuses to consume all of the available physical RAM. Considering remoting to move data in and out of this process. Need something that's quick and dirty and easy to implement, but that's performant and secure at the same time. Any suggestions / tutorials? Would prefer not to go on the TCP/IP stack (socket) as it is not...
8
2587
by: JamesHoward | last post by:
I am looking for a way of performing inter process communication over XML between a python program and something else creating XML data. What is the best way of performing this communication? I could bind a socket to localhost and perform the data transfer that way, but that seems inefficient due to the addition of TCP/IP or UDP/IP overhead. Is there a way to stream data via a custom datastream (I.E. not STDIO, STDERR, etc)? Thanks...
0
8667
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8610
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8469
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7145
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6104
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1471
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.