views:

370

answers:

1

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?

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