.net - Address of new ServiceHost always same as the old one? -
.net - Address of new ServiceHost always same as the old one? -
i have next test code first tries open servicehost on invalid address, when faults calls both abort() , dispose (the latter isn't required). creates new servicehost , attempts open on (valid) address, still generates error saying old address invalid.
class programme { static void main(string[] args) { testhost("net.tcp://0.0.0.1:8081/testuri"); testhost("net.tcp://0.0.0.0:8081/testuri"); } static void testhost(string address) { servicehost host = null; seek { host = new servicehost(typeof(mycontract), new uri(address)); host.open(); console.writeline("host opened successfully"); host.close(); } grab (exception ex) { if (host != null) { host.abort(); ((idisposable)host).dispose(); } console.writeline(ex.message); } } } [servicecontract] public interface imycontract { [operationcontract] void method(); } class mycontract : imycontract { public void method() { console.writeline("method called"); } } this generates next output:
a tcp error (10049: requested address not valid in context) occurred while listening on ip endpoint=0.0.0.1:8081. tcp error (10049: requested address not valid in context) occurred while listening on ip endpoint=0.0.0.1:8081. note endpoint same in both errors. (if reverse operations, first phone call succeed , sec fail).
seems cache in works here, how can clear , have new servicehost utilize address provided instead of old address?!
i'm not sure i'm much help either, other pointing out others have had similar problems without obvious solution.
servicehost fail open() 1 time again new servicehost instance when failed first time in wcf self-host wcf: servicehost problem (cached adresses?)a suggestion: have found phone call close() doesn't shut downwards whole stack, right downwards actual socket; can happen several seconds later. manifests errors saying ports in utilize when seek reopen them after closing them. wonder if similar going on in test code, , sec phone call trying reopen previous host because it's still floating around somewhere until tidied up. seek putting delay in between calls testhost and/or forcing garbage collection , see if changes behaviour.
a question: need bind specific ip address? under circumstances invalid , able retry different address? bind addresses (e.g.: net.tcp://localhost:8081/testuri)?
.net wcf .net-4.5
Comments
Post a Comment