views:

135

answers:

2

Hi guys,

I have two MFC C++ desktop applications exchanging string commands using named pipes. All good and reliable.

Now, I have to add clients that are written in .NET C# using SilverLight controls. I know how to do named pipes in C#. But my first attempt to mix those failed: cannot connect clients to running servers.

Is there anything I am missing and that "mixed nuts" schema must work? or it's a "language barrier" :-)

Cheers, Val

A: 

Assuming you try to use WCF for communication, NetNamedPipeBinding is not available for Silverlight as far as I know, and if you try to do P/Invoke that will be blocked from a Silverlight app running inside a browser due to security constraints of the browser.

You do have messaging across Silverlight plug-ins available. Paul Stubbs has a blog post showing how that works in Silverlight 3.

As long as your Silverlight app runs in a browser and you have to communicate with a MFC server you have to implement some other protocol besides named pipes. And I don't think you are allowed to use P/Invoke if the Silverlight app runs out-of-browser either. It's a limitation of Silverlight.

Mikael Svenson
What do you think about sockets?
val
What about creating a server proxy between the mfc server and the client which uses a wcf binding with the client and named pipes with the mfc server?
Mikael Svenson
A: 

If you are willing to deal with COM Interop there might be a way.

It will let you communicate with a local app that has COM Interop. You can then pipe the messages from Silverlight to the app that you want using whatever is available, since the COM object doesn't have the same restrictions as Silverlight. This would require Silverlight 4, and also setting up that COM Interop target on the client side.

Rangoric
But note that the silverlight app has to run with elevated privileges for this to work. (out of browser)
Mikael Svenson
Com Interop sounds very interesting. But I am using Silverligth 3 at this time and I am in the middle of the project... Uhm, need to regroup, I think :-)Do you see sockets a better choice? MFC -> Silverlight
val
Ouch. In that case the best I can think of is using the server hosting the Silverlight as a mediator (I.E. have the MFC send a message to the server via http post, then have the Silverlight app poll the server every so often) or setting up the localhost as a server in some fashion.Any idea I come up with is non-trivial, though, compared to what you have going between the MFC apps. However, using the Server Hosting the Silverlight as a mediator would be the next idea I look into.
Rangoric
Thanks buddy, I am up for some fun this week :-)
val