gpt4 book ai didi

c# - 错误 "An attempt was made to access a socket in a way forbidden by its access permissions"

转载 作者:太空宇宙 更新时间:2023-11-03 20:59:53 26 4
gpt4 key购买 nike

在本地机器上运行 WCF 服务进行测试。在 App.config 中我有:

<system.serviceModel>
<services>
<service name="Pizza.Services.PizzaService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733"/>
</baseAddresses>
</host>
<endpoint address="pizza"
binding="basicHttpBinding"
contract="Pizza.Services.IPizzaService">

</endpoint>
<endpoint address="net.tcp://localhost:8733/pizza"
binding="netTcpBinding"
contract="Pizza.Services.IPizzaService">
</endpoint>
</service>
</services>

如果我从 VS2015 运行应用程序(作为普通用户或管理员),我得到:

A TCP error (10013: An attempt was made to access a socket in a way forbidden by its access permissions) occurred while listening on IP Endpoint=0.0.0.0:8733. ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions

现在我的同事含糊地解释了 Windows 10 的一项安全功能,该功能将阻止用户获取随机端口并将其提供给某些服务。所以我以管理员身份打开命令提示符并执行了以下操作:

netsh http add urlacl url=http://+:8733/ user=Everyone

还是一样的错误

我注意到了类似的问题,但我觉得它们都没有解决我的问题。

编辑:我忘记提及的另一件事是我尝试关闭防火墙和防病毒软件但没有成功。

最佳答案

端点绑定(bind)搞砸了。我更改了以下端口:

<endpoint address="net.tcp://localhost:8733/pizza"
binding="netTcpBinding"
contract="Pizza.Services.IPizzaService">
</endpoint>

从 8733 到 8732 并且有效。基本上,两个端点试图使用相同的端口。

关于c# - 错误 "An attempt was made to access a socket in a way forbidden by its access permissions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46606432/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com