How to make a WCF named pipe address equal to a Wi

2019-07-04 11:20发布

I noticed that WCF's named pipe address

net.pipe://localhost/mynamedpipe

and Windows API's

\\.\pipe\mynamedpipe

don't collide. Why is that? How can I make them point to the same pipe?

3条回答
不美不萌又怎样
2楼-- · 2019-07-04 11:50

Linking native and WCF pipes is not possible according to this from Stephen Cleary. This makes sense, given the context of disjoint pipe namespaces for WCF and Win32.

All the WCF bindings that start with "Net" are .NET-specific. They use a certain protocol (which is undocumented AFAIK) that may change in the future.

If you just need to know the pipename, you may be able to work this out (by elimination?) using pipelist from Sysinternals. I imagine that under the WCF covers there lurks a native named pipe...

查看更多
劫难
3楼-- · 2019-07-04 11:58

There is no documented way of doing that. After a few tests I came to the following conclusions:

If you have a WCF server and a Win32 C++ client, the last one will see the first one address as a UUID in the following format:

12345678-1234-1234-1234-123456789abc

And this UUID seems random, since it changes for the same WCF address every time the server is started.

I don't know if a Win32 C++ named pipe server with a GUID format address will be visible from a WCF client, but I'm sure that if it does, the server will have to implement the poorly documented protocol used by WCF.

The documentation for such protocol is provided as an answer to my previous question on this subject.

EDIT Further research revealed that the pipe address is stored in the FileMapping. This entry address in its turn is a base64 encoded hash of a normalized version of the NetNamedPipe address.

查看更多
Fickle 薄情
4楼-- · 2019-07-04 12:03

See here for some detail I discovered on this while trying to do something similar.

You can't control the WCF end of the pipe (well, not without throwing away netNamedPipeBinding and creating your own named pipe transport instead)... but you can locate and open the WCF pipe from native code if you're prepared to work at it.

查看更多
登录 后发表回答