IpcChannel will not create

Q

quilkin

Hi,
I have a Windows service which communicates to a user app via IpcChannel
remoting.
It all works fine until the service is stopped and restarted (or restarted
via Management Console Services), when the lines
_ipc = new IpcChannel(properties, clientProv, serverProv);
ChannelServices.RegisterChannel(_ipc, true);
fail because _ipc returns 'null'.
I did try have a statement
ChannelServices.UnregisterChannel(_ipc);
when the service stops but that made no difference.
If I wait several minutes before restarting the service, it usually restarts
OK, but I need it to restart in less than one minute if there's a problem
with it. Note, it always restarts OK on Vista, this problem is only evident
on XP!!

So, how do ensure that the previous incarnation of the remoting channel is
always deleted?
 
N

Nicholas Paldino [.NET/C# MVP]

Well, this kind of indicates that you are not keeping track of the
channel in your service like you should. There should only be some very
limited places where you would need to create/destroy the channel, are you
sure you are doing it in the appropriate places?
 
Q

quilkin

Nicholas,

The channel is created once, and once only, in the 'OnStart()' method of the
service. _ipc is currently a class property but we have also tried it as a
local in the constructor so it should have got destroyed there.
Can't use the 'using' statement because IpcChannel is not 'disposable'.
Presumably something in XP is doing a cleanup several minutes after the
service closes. But in Vista it's cleaned straight away. is this a clue?

Nicholas Paldino said:
Well, this kind of indicates that you are not keeping track of the
channel in your service like you should. There should only be some very
limited places where you would need to create/destroy the channel, are you
sure you are doing it in the appropriate places?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

quilkin said:
Hi,
I have a Windows service which communicates to a user app via IpcChannel
remoting.
It all works fine until the service is stopped and restarted (or restarted
via Management Console Services), when the lines
_ipc = new IpcChannel(properties, clientProv,
serverProv);
ChannelServices.RegisterChannel(_ipc, true);
fail because _ipc returns 'null'.
I did try have a statement
ChannelServices.UnregisterChannel(_ipc);
when the service stops but that made no difference.
If I wait several minutes before restarting the service, it usually
restarts
OK, but I need it to restart in less than one minute if there's a problem
with it. Note, it always restarts OK on Vista, this problem is only
evident
on XP!!

So, how do ensure that the previous incarnation of the remoting channel is
always deleted?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top