[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Emil Solakov

8/24/2004 2:18:00 PM

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.


2 Answers

Sam Santiago

8/24/2004 4:39:00 PM

0

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/frlrfsystemappdomainclassunloa...

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/cpconprogrammingwithapplicationd...

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

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Emil Solakov" <NOSPAMesolakov@technologicaREMOVE-THIS.com> wrote in message
news:uXiS0UeiEHA.3536@TK2MSFTNGP12.phx.gbl...
> 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.
>
>


Jason

8/31/2004 3:12:00 AM

0

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" <ssantiago@n0spam-SoftiTechture.com> wrote in message
news:OrcfMjfiEHA.712@TK2MSFTNGP09.phx.gbl...
> 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/frlrfsystemappdomainclassunloa...
>
> 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/cpconprogrammingwithapplicationd...
>
> This would allow you to truly isolate your code and be able to control
> stopping it completely.
>
> Thanks,
>
> Sam
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTe...
> _______________________________
> "Emil Solakov" <NOSPAMesolakov@technologicaREMOVE-THIS.com> wrote in
message
> news:uXiS0UeiEHA.3536@TK2MSFTNGP12.phx.gbl...
> > 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.
> >
> >
>
>