Windows Service
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.remoting.

Post a new message to this list...

Emil Solakov
Hi all,
I have a Remoting application that using http channel.
When I tried to make Windows Service from this application all seems to be
all right until I restart service. I have the following Exception.

Service cannot be started. System.Net.Sockets.SocketException: Only one
usage of each socket address (protocol/network address/port) is normally
permitted
at
System.Runtime.Remoting.Channels.Http.HttpServerChannel.StartListening(Objec
t data)
at System.Runtime.Remoting.Channels.Http.HttpServerChannel.SetupChannel()
at System.Runtime.Remoting.Channels.Http.HttpServerChannel..ctor(String
name, Int32 port, IServerChannelSinkProvider sinkProvider)

Service OnStop method is:
_httpChannel.StopListening(null);
ChannelServices.UnregisterChannel(_httpChannel);
_httpChannel = null;
GC.Collect();
GC.WaitForPendingFinalizers();

But it doesn't help. I must wait around 20 seconds before start service
again.
Is there a way to stop HttpServerChannel's socked immediately, because
otherwise I can't restart my service.

Thanks in advance.

Reply to this message...
 
    
Sam Santiago
Are you doing any threading in your application? You might want to try
AppDomain.Unload:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemappdomainclassunloadtopic.asp

You could also create a child AppDomain at startup to actually run your
logic and with the OnStop method you could perform an Unload on that
AppDomain:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconprogrammingwithapplicationdomains.asp

This would allow you to truly isolate your code and be able to control
stopping it completely.

Thanks,

Sam

--
_______________________________
Sam Santiago
Click here to reveal e-mail address
http://www.SoftiTechture.com
_______________________________
"Emil Solakov" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jason
did you make sure you did:

RemotingServices.Disconnect(obj)

on the MarshalByObjectRef that you're serving up on that channel before you
unregister the channel (if you used RemotingServices.Marshal(obj, URI))?

"Sam Santiago" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.AppDomain
System.GC
System.Net.Sockets.SocketException
System.Runtime.Remoting.Channels.ChannelServices
System.Runtime.Remoting.Channels.Http.HttpServerChannel
System.Runtime.Remoting.Channels.IServerChannelSinkProvider
System.Runtime.Remoting.RemotingServices




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com