WCF服务器没有配置文件 [英] WCF Server without config file

查看:108
本文介绍了WCF服务器没有配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经厌倦了处理配置文件,所以我试图安装一个WCF服务仅code的。

到目前为止,我有这样的:

  m_ServiceHost =新的ServiceHost(ME)
    m_ServiceHost.AddServiceEndpoint(
          的GetType(Aam.AamServiceFramework.IServiceMonitor)
          新NetTcpBinding的,的net.tcp://本地主机:6000)
    m_ServiceHost.AddServiceEndpoint(
          的GetType(IMetadataExchange接口),
          新NetTcpBinding的,的net.tcp://本地主机:6500)
    m_ServiceHost.Open()
 

这工作,如果我注释掉IMetadataExchange接口。如何处理那件?

解决方案

  m_ServiceHost.Description.Behaviors.Add(新的ServiceMetadataBehavior())
    m_ServiceHost.AddServiceEndpoint(
             的GetType(IMetadataExchange接口),
             MetadataExchangeBindings.CreateMexTcpBinding(),
             的net.tcp://本地主机:6595)
 

I'm tired of dealing with config files so I'm trying to setup a WCF service in code only.

So far I have this:

    m_ServiceHost = New ServiceHost(Me)
    m_ServiceHost.AddServiceEndpoint( 
          GetType(Aam.AamServiceFramework.IServiceMonitor), 
          New NetTcpBinding, "net.tcp://localhost:6000)
    m_ServiceHost.AddServiceEndpoint(
          GetType(IMetadataExchange), 
          New NetTcpBinding, "net.tcp://localhost:6500)
    m_ServiceHost.Open()

This works if I comment out the IMetadataExchange. How do I handle that piece?

解决方案

    m_ServiceHost.Description.Behaviors.Add(New ServiceMetadataBehavior())
    m_ServiceHost.AddServiceEndpoint(
             GetType(IMetadataExchange), 
             MetadataExchangeBindings.CreateMexTcpBinding(), 
             "net.tcp://localhost:6595")

这篇关于WCF服务器没有配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆