I’m following this tutorial on WCF and everything works fine. Seems like with that simple code I should be able to call any kind of methods from my clients to a server. I’m only interested on pipes, no networking at all.
I remember reading somewhere that these objects returned from the server, such as pipeProxy in this code:
IStringReverser pipeProxy = pipeFactory.CreateChannel();
will last only 5 minutes and then be disposed or finalized or something like that. Is this true? Will I have to call my ChannelFactory‘s CreateChannel every time I want to call one of my server’s methods? Also, can I keep my ChannelFactory instance or will it also commit suicide after a while?
I can’t find much information on these details and what I do find are huge advanced tutorials that talk mostly about stuff I don’t care about like http and networking. All I want is to have a basic communication between two applications in the same machine. Being able to call a method from application A to application B is all I need.
So is there any gotchas I should be afraid of or is the code posted in the linked tutorial enough? Can I just take the code in the tutorial and simply keep adding methods to the sample class and everything will work out just fine? Or is there anything else I need to know?
You can keep your ChannelFactory, in fact you should as it is expensive to create one.
On the other hand creating new channels is not an expensive operation and you can just create new ones each time you need to make (or retry) a call.
I didn’t find the reference to the 5 minutes, so I guess that what the tutorial meant is that if you keep a connection open for more than 5 minutes then it will timeout. If you want to keep a connection open all times between the two applications I’ll suggest looking into
DuplexChannelsinstead