0

当我在我的配置文件中添加 portSharingEnabled 功能时,我得到了错误调用

The service endpoint failed to listen on the URI 'net.tcp://localhost:5555/Calculator'
because access was denied.  Verify that the current user is granted access in the 
appropriate allowAccounts section of SMSvcHost.exe.config.

老实说,我只是不明白为什么我会收到这个错误以及如何解决它。

这是我的配置文件详细信息

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="CalculatorServer.Calculator" behaviorConfiguration="CalculatorBehavior">
                <endpoint address="net.tcp://localhost:5555/Calculator" binding="netTcpBinding" bindingConfiguration="PortSharingBinding"
                    contract="CalculatorInterFace.ICalculator" />

                <endpoint address="net.tcp://localhost:5555/Calculator/mex"
                          binding="mexTcpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <bindings>
            <netTcpBinding>
                <binding name="PortSharingBinding" portSharingEnabled="true">
                    <security mode="None"/>
                </binding>
            </netTcpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="CalculatorBehavior">
                    <serviceMetadata httpGetEnabled="false"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

这样我就尝试开始我的服务。

public class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(Calculator)))
            {
                host.Open();
                Console.WriteLine("Server Started");
                Console.ReadLine();
                host.Close();
            }
        }
    }

请指导我该做什么以及我需要在我的配置文件中添加什么来修复此错误。谢谢

4

2 回答 2

3

当您启动 Microsoft Visual Studio 20?? 时,右键单击该图标并选择“以管理员身份运行”。

于 2014-01-25T12:19:34.300 回答
1

停止以下所有服务,然后按顺序启动:

  • Net.Tcp 侦听器适配器

  • Net.Tcp 端口共享服务

  • Net.Pipe 侦听器适配器

于 2014-01-24T14:32:40.320 回答