Getting AddressAlreadyInUseException after upgrading to .NET 4.5

后端 未结 2 1549
Happy的楠姐
Happy的楠姐 2021-01-02 23:53

I recently installed the new .NET Framework 4.5 (previously was 4.0 installed) on my Server and I´m getting a System.ServiceModel.AddressAlreadyInUseException w

相关标签:
2条回答
  • 2021-01-03 00:21

    This is because of some limitations in using the same port for both the netTcp endpoint and mex endpoint documented here refer section "Sharing a port between a service endpoint and a mex endpoint using the NetTcpBinding". In 4.0 the defaults for listenBackLog and MaxConnections were 10. In 4.5 these defaults were revised as 12 * ProcessorCount. This exception happens when you try to share a port between netTcpBinding and mex endpoint provided you have different values for these two properties. In 4.0 this worked fine as you have set these to the default values (10) and thus these settings do not differ on both endpoints. But in 4.5 these are left as 10 for netTcp endpoint, but computed as 12* ProcessorCount. So the exception.

    To solve this issue there are 2 ways:

    1. Remove these settings (listenBackLog and MaxConnections) from the config. In this way you will get a default of 12 * Processor count automatically which is > than 4.0 defaults.
    2. Follow the work around of configuring mex endpoint on a different port as described in documentation

    Please check out this blog for more details.

    0 讨论(0)
  • 2021-01-03 00:38

    When you host a WCF service in a console application you need to copy the App.config file from the WCF project to the console app and then delete the App.config file from the WCF project,if you don't you can also get the above error.

    0 讨论(0)
提交回复
热议问题