我是否需要svc文件为非HTTP服务设置Castle Wcf设施

我是否需要svc文件为非HTTP服务设置Castle Wcf设施,wcf,castle-windsor,castle,net.tcp,wcffacility,Wcf,Castle Windsor,Castle,Net.tcp,Wcffacility,我对castle wcf设施的注册感到困惑 我读了一些BasicHttpBinding的博客文章。 但找不到用于设置net.tcp设置的清晰易用示例 我想从控制台应用程序托管服务 我写了这样的东西。。。你能看到这里有问题吗 _container = new WindsorContainer(); _container.AddFacility<WcfFacility>(); _container.Register(Component.For<IMembershipService

我对castle wcf设施的注册感到困惑

我读了一些BasicHttpBinding的博客文章。 但找不到用于设置net.tcp设置的清晰易用示例

我想从控制台应用程序托管服务

我写了这样的东西。。。你能看到这里有问题吗

_container = new WindsorContainer();
_container.AddFacility<WcfFacility>();

_container.Register(Component.For<IMembershipService>().ImplementedBy<MembershipService>()
    .AsWcfService(
        new DefaultServiceModel()
            .AddEndpoints(WcfEndpoint
                    .BoundTo(new NetTcpBinding() { PortSharingEnabled = false })
                    .At("net.tcp://localhost/MembershipService")
            )
            .PublishMetadata()
    )
);
\u container=new WindsorContainer();
_container.AddFacility();
_container.Register(Component.For().ImplementedBy()实现)
.ASWCF服务(
新的DefaultServiceModel()
.添加点(WCP点)
.BoundTo(新的NetTcpBinding(){PortSharingEnabled=false})
.At(净额)。tcp://localhost/MembershipService")
)
.PublishMetadata()
)
);

如果您希望发布元数据,您需要启用端口共享(让MEX端点与常规TCP端口共享同一端口-如果将此设置为false,您将获得AddressalReadyUse异常),并且您可能需要在URL上指定一个端口(不确定TCP将使用哪个端口),因此您的代码应该是(假设端口8080适合您):

\u container.Register(Component.For().ImplementedBy()实现)
.ASWCF服务(
新的DefaultServiceModel()
.添加点(WCP点)
.BoundTo(新的NetTcpBinding(){PortSharingEnabled=true})
.At(净额)。tcp://localhost:8080/MembershipService")
)
.PublishMetadata()
)
);

这在castle windsor 3.0中运行良好。

请记住,可能不允许用户使用端口共享。我遇到了这个问题,我得到了一个通信异常,提示我可以编辑文件SMSvcHost.exe.config中的allowAccounts部分以允许用户这样做。但此解决方案不可行,因为该文件是loc在C:\Windows\Microsoft.NET\…我目前的解决方案:删除Mex端点/PublishMetadata()。如果将来需要,我将使用第二个绑定配置发布元数据。哦,在我拥有“NET.Tcp端口共享服务”之前在“我的windows服务”中禁用。您的最终用户可能也禁用了此功能,并且可能不允许启用它(并且使用安装程序启用它不是一个很好的选项)
_container.Register(Component.For<IMembershipService>().ImplementedBy<MembershipService>()
    .AsWcfService(
        new DefaultServiceModel()
            .AddEndpoints(WcfEndpoint
                    .BoundTo(new NetTcpBinding() { PortSharingEnabled = true})
                    .At("net.tcp://localhost:8080/MembershipService")
            )
            .PublishMetadata()
    )
);