首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带有tcp绑定和portSharingEnabled问题的WCF

带有tcp绑定和portSharingEnabled问题的WCF
EN

Stack Overflow用户
提问于 2014-01-24 21:59:19
回答 2查看 1.3K关注 0票数 0

当我在我的配置文件中添加portSharingEnabled特性时,我会收到错误调用

代码语言:javascript
复制
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.

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

下面是我的配置文件的详细信息

代码语言:javascript
复制
<?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>

这样我就可以开始我的服务了。

代码语言:javascript
复制
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();
            }
        }
    }

请指导我做些什么,以及我需要在配置文件中添加哪些内容来修复此错误。谢谢

EN

回答 2

Stack Overflow用户

发布于 2014-01-25 20:19:34

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

票数 3
EN

Stack Overflow用户

发布于 2014-01-24 22:32:40

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

Adapter

  • Net.Tcp端口共享Service

  • Net.Pipe侦听器适配器
  • Net.Tcp侦听器
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21334561

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档