473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

IPC between unmanaged and managed code

Hi all, my current project is completely written in native C++, and
for some reason I need to write a standalone .Net program to do some
work for it. Therefore, I need to find an effective way of IPC between
my unmanaged code and managed code. What's most appropriate IPC
solution for this? Thanks in advance.

Alex Y Wang
Nov 21 '07 #1
7 2659
Probably Named Pipes. A lot depends on the format of the data that's being
transferred back and forth.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"Alex Y Wang" wrote:
Hi all, my current project is completely written in native C++, and
for some reason I need to write a standalone .Net program to do some
work for it. Therefore, I need to find an effective way of IPC between
my unmanaged code and managed code. What's most appropriate IPC
solution for this? Thanks in advance.

Alex Y Wang
Nov 21 '07 #2
I would agree, but one might want to think of hosting the components
that do the work in COM+ as well, which provide process isolation. One
wouldn't have to worry about creating the message pattern/protocol that is
needed when using a raw named pipe (unless of course, the operations are so
simple that the time needed to develop it is insignificant).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:43**********************************@microsof t.com...
Probably Named Pipes. A lot depends on the format of the data that's being
transferred back and forth.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"Alex Y Wang" wrote:
>Hi all, my current project is completely written in native C++, and
for some reason I need to write a standalone .Net program to do some
work for it. Therefore, I need to find an effective way of IPC between
my unmanaged code and managed code. What's most appropriate IPC
solution for this? Thanks in advance.

Alex Y Wang

Nov 21 '07 #3
On Nov 21, 8:29 am, Alex Y Wang <redflying...@gmail.comwrote:
Hi all, my current project is completely written in native C++, and
for some reason I need to write a standalone .Net program to do some
work for it. Therefore, I need to find an effective way of IPC between
my unmanaged code and managed code. What's most appropriate IPC
solution for this? Thanks in advance.

Alex Y Wang
Hi Alex,
In addition to what Peter and Nicolas suggested, you could also use
Interop to take advantage of a .NET IPC, like remoting. In one of my
previous projects, I took this approach by implementing a remoting-
capable .NET class, and using it via Interop inside of a native C++
service, and it worked fine.

I think your choice of IPC really depends on what services you need
from the IPC, more than what language your two programs are written
in.

John
Nov 21 '07 #4
I would second (third?) what Peter and Nicholas have said - Pipes are the
easiest answer.

If you use .Net 3.5 (VS 2008) there is a complete set of classes for dealing
with Pipes in the .Net code. If you use an older verison (.Net 1.1 / .Net
2.0), you'll have to roll your own.

(Hrm. I'm not sure about .Net 3.0. I wonder if that has the Pipe classes?
They seem like something that would have been shipped as part of WCF, so I
would expect .Net 3.0 to have them...)

From what I remember, dealing with pipes from C++ / Win32 was pretty easy.

--
Chris Mullins

"Alex Y Wang" <re**********@gmail.comwrote in message
news:cb**********************************@f3g2000h sg.googlegroups.com...
Hi all, my current project is completely written in native C++, and
for some reason I need to write a standalone .Net program to do some
work for it. Therefore, I need to find an effective way of IPC between
my unmanaged code and managed code. What's most appropriate IPC
solution for this? Thanks in advance.

Alex Y Wang

Nov 21 '07 #5
Chris,

Agreed with most you've said, except that pipes are part of 3.0 ; WCF's
"ipc" channel is not the same as a "named pipe", it's a channel that uses
Memory Mapped file(s) for IPC , named pipes are part of 3.5 (
System.IO.Pipes).

Willy.

"Chris Mullins [MVP - C#]" <cm******@yahoo.comwrote in message
news:eD**************@TK2MSFTNGP03.phx.gbl...
>I would second (third?) what Peter and Nicholas have said - Pipes are the
easiest answer.

If you use .Net 3.5 (VS 2008) there is a complete set of classes for
dealing with Pipes in the .Net code. If you use an older verison (.Net 1.1
/ .Net 2.0), you'll have to roll your own.

(Hrm. I'm not sure about .Net 3.0. I wonder if that has the Pipe classes?
They seem like something that would have been shipped as part of WCF, so I
would expect .Net 3.0 to have them...)

From what I remember, dealing with pipes from C++ / Win32 was pretty easy.

--
Chris Mullins

"Alex Y Wang" <re**********@gmail.comwrote in message
news:cb**********************************@f3g2000h sg.googlegroups.com...
>Hi all, my current project is completely written in native C++, and
for some reason I need to write a standalone .Net program to do some
work for it. Therefore, I need to find an effective way of IPC between
my unmanaged code and managed code. What's most appropriate IPC
solution for this? Thanks in advance.

Alex Y Wang


Nov 21 '07 #6

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:OM**************@TK2MSFTNGP03.phx.gbl...
Chris,

Agreed with most you've said, except that pipes are part of 3.0 ; WCF's
"ipc" channel is not the same as a "named pipe", it's a channel that uses
Memory Mapped file(s) for IPC , named pipes are part of 3.5 (
System.IO.Pipes).

Willy.


Above is incorrect, System.Runtime.Remoting "Ipc" channel (V2.0) is mapped
over Shared Memory, while the WCF (V3.0) has a channel that uses "Named
Pipes", however, the pipe classes are private, so cannot be used from within
your code. Sorry for the confusion

Nov 21 '07 #7
Thanks a lot for the responses. I'll give named pipe a go then. All I
want to do is to have the .Net program to act as a temporary server.
It should send back responses as well as data to the native program
depending what requests it received from the native program.
Nov 22 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
2
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
12
by: doug | last post by:
I understand the basics of what managed code offers and that you open yourself up to security issues if you allow unmanaged code. We already have a decent amount of VB6 code to include COM DLLs. ...
6
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.