HighTechTalks DotNet Forums  

Named pipes class for .NET

Dotnet Framework (SDK) microsoft.public.dotnet.framework.sdk


Discuss Named pipes class for .NET in the Dotnet Framework (SDK) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
David Thielen
 
Posts: n/a

Default Named pipes class for .NET - 08-23-2009 , 02:43 PM






Hi;

Is there a simple, easy to use implementation of named pipes for .NET?
One that is very clear in exactly how it should be used AND implements
them correctly?

There are a ton of implementations out there - and they all take a
different approach. All we need is a way fortwo apps on the same
machine to talk to each other.

thanks - dave

david@at-at-at (AT) windward (DOT) dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Reply With Quote
  #2  
Old   
Eugene Mayevski
 
Posts: n/a

Default Re: Named pipes class for .NET - 08-24-2009 , 04:43 AM






Quote:
There are a ton of implementations out there - and they all take a
different approach. All we need is a way fortwo apps on the same
machine to talk to each other.

Named pipes are not the best mechanism for solving your task due to security
complexities and some bugs in internal named pipe implementation. Memory
Mapped Files with some synchronization primitives or Windows Messages are
way better.

You might want to take a look at MsgConnect product, which offers a uniform
way to send messages between applications running on the same or different
computers. See http://www.eldos.com/msgconnect/

--
With best regards,
Eugene Mayevski

Reply With Quote
  #3  
Old   
Hongye Sun [MSFT]
 
Posts: n/a

Default RE: Named pipes class for .NET - 08-24-2009 , 05:16 AM



Hi Dave,

Thanks for your post.

There are many named pipe implemenation because there are many ways to do
it.

In order to make sure which is the best way to implement it, you have to
clarify following questions:

1. Does your application require asynchronous usage of Named Pipe?
2. Are writing native code or managed code?

Since .NET 2.0, it adds a new namespace: System.IO.Pipe. It eases the usage
of named pipe in .NET langauges instead of interop.

For asynchronous usage of Named Pipe, it depends on your requirement of the
two apps. Do you want to the sender to wait for the receiver to complete?

CodeFX has a very good example to explain the usage of Named Pipe in both
native and .NET. For detail, it has a code project article to explain named
pipe:
http://www.codeproject.com/KB/threads/CodeFX_IPC.aspx

For downloading the latest version of sample code, please go to:
http://cfx.codeplex.com/

Please let me know if codefx sample code meets your needs. Thanks.

Sincerely,
Hongye Sun (hongyes (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.
*
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
*
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within*2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply With Quote
  #4  
Old   
David Thielen
 
Posts: n/a

Default Re: Named pipes class for .NET - 08-29-2009 , 03:23 PM



On Mon, 24 Aug 2009 12:43:52 +0300, "Eugene Mayevski"
<mayevski (AT) eldos (DOT) com> wrote:

Quote:
There are a ton of implementations out there - and they all take a
different approach. All we need is a way fortwo apps on the same
machine to talk to each other.


Named pipes are not the best mechanism for solving your task due to security
complexities and some bugs in internal named pipe implementation. Memory
Mapped Files with some synchronization primitives or Windows Messages are
way better.

You might want to take a look at MsgConnect product, which offers a uniform
way to send messages between applications running on the same or different
computers. See http://www.eldos.com/msgconnect/
MsgConnect looks like overkill for our use. Is there an example
somewhere of a simple way to use messages? We just need to send
receive a byte (which has a value of 0 - 5 for what is occuring).

But... We also need to SEND a message, not just post it, where we will
get a byte back.

??? - thanks - dave

david@at-at-at (AT) windward (DOT) dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Reply With Quote
  #5  
Old   
David Thielen
 
Posts: n/a

Default Re: Named pipes class for .NET - 08-29-2009 , 03:31 PM



On Mon, 24 Aug 2009 10:16:34 GMT, hongyes (AT) online (DOT) microsoft.com
("Hongye Sun [MSFT]") wrote:

Quote:
Hi Dave,

Thanks for your post.

There are many named pipe implemenation because there are many ways to do
it.

In order to make sure which is the best way to implement it, you have to
clarify following questions:

1. Does your application require asynchronous usage of Named Pipe?
2. Are writing native code or managed code?

Since .NET 2.0, it adds a new namespace: System.IO.Pipe. It eases the usage
of named pipe in .NET langauges instead of interop.

For asynchronous usage of Named Pipe, it depends on your requirement of the
two apps. Do you want to the sender to wait for the receiver to complete?

CodeFX has a very good example to explain the usage of Named Pipe in both
native and .NET. For detail, it has a code project article to explain named
pipe:
http://www.codeproject.com/KB/threads/CodeFX_IPC.aspx

For downloading the latest version of sample code, please go to:
http://cfx.codeplex.com/

Please let me know if codefx sample code meets your needs. Thanks.
Your project CSSendWM_COPYDATA looks good except - we can't control
the class name of the window (it's a C# app) and we can't control the
caption because we localize our app.

Is there any way to do messages in this case?

thanks - dave

david@at-at-at (AT) windward (DOT) dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Reply With Quote
  #6  
Old   
Eugene Mayevski
 
Posts: n/a

Default Re: Named pipes class for .NET - 08-30-2009 , 01:35 AM



Quote:
MsgConnect looks like overkill for our use. Is there an example
somewhere of a simple way to use messages? We just need to send
receive a byte (which has a value of 0 - 5 for what is occuring).

There are several samples included in the evaluation installation of
MsgConnect, including simple SendNote demo.

And yes, MsgConnect supports both SendMessage and PostMessage approaches.
Actually it implements the same messaging API as Windows offers, but with
possibility to use different transports and send messages over the network.

--
With best regards,
Eugene Mayevski
http://www.eldos.com/ - security and virtual storage components

Reply With Quote
  #7  
Old   
Hongye Sun [MSFT]
 
Posts: n/a

Default Re: Named pipes class for .NET - 08-31-2009 , 05:08 AM



Hi Dave,

Other than find window by its caption, you can also get it by process name,
here is an sample code:

Process[] processes = Process.GetProcessesByName("notepad");
foreach (Process p in processes)
{
IntPtr pFoundWindow = p.MainWindowHandle;
// Do something with the handle...
//
}

Another alternative is still using FindWindow, but by class name instead of
caption.
You have to register the window class name before find it. Here is an
example:

http://stackoverflow.com/questions/128561/registering-a-custom-win32-window-
class-from-c

Sincerely,
Hongye Sun (hongyes (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.
*
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply With Quote
  #8  
Old   
David Thielen
 
Posts: n/a

Default Re: Named pipes class for .NET - 09-02-2009 , 03:18 PM



On Mon, 31 Aug 2009 10:08:55 GMT, hongyes (AT) online (DOT) microsoft.com
("Hongye Sun [MSFT]") wrote:

Quote:
Hi Dave,

Other than find window by its caption, you can also get it by process name,
here is an sample code:

Process[] processes = Process.GetProcessesByName("notepad");
foreach (Process p in processes)
{
IntPtr pFoundWindow = p.MainWindowHandle;
// Do something with the handle...
//
}

Another alternative is still using FindWindow, but by class name instead of
caption.
You have to register the window class name before find it. Here is an
example:

http://stackoverflow.com/questions/128561/registering-a-custom-win32-window-
class-from-c
I'll try the process name. We can't do classname because C# doesn't
let you set the class name of a C# Form window.

thanks - dave

david@at-at-at (AT) windward (DOT) dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Reply With Quote
  #9  
Old   
Hongye Sun [MSFT]
 
Posts: n/a

Default Re: Named pipes class for .NET - 09-06-2009 , 08:27 PM



Thanks, Dave,

Please let me know if you need any further support for this issue. Have a
nice day.

Sincerely,
Hongye Sun (hongyes (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided.
*
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply With Quote
  #10  
Old   
David Thielen
 
Posts: n/a

Default Re: Named pipes class for .NET - 09-28-2009 , 12:01 PM



On Mon, 07 Sep 2009 01:27:01 GMT, hongyes (AT) online (DOT) microsoft.com
("Hongye Sun [MSFT]") wrote:

Quote:
Thanks, Dave,

Please let me know if you need any further support for this issue. Have a
nice day.
Hi;

This didn't work. We can post a message from our Office AddIn app to
our applet because it is a Forms based app and so it always has a main
window and that window is our program.

But we cannot post a message to aour AddIn because:

1) There may be no Window - it is running on Word/Excel/PPT but most
of the time we have no window open.

2) We can get the winword process and Word's main window - but we have
no way from that to get our AddIn's window (if we had a hidden one
that always existed).

So we're back to our core problem. How do we do IPC between an app and
an Office AddIn. All we need to do is pass a byte (that can have 5
different values).

We can't do find by class because we're .NET and have no control over
the class.

We can't do find by caption because our app is translated and so the
caption depends on the language it is running under.

I still think named pipes is the best approach - but I think they are
not shutting down when the program is exited.

So my two questions are:

1) What is the best way to perform IPC? This will always be on the
local computer.

2) If it's named pipes, is there a link to a correct example of how to
do this from .NET? Preferably a very simple implementation as all we
need to do is get a byte value across.

thanks - dave

david@at-at-at (AT) windward (DOT) dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.