.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification