Jonathan Allen
Jonathan Allen

Reputation: 70307

WCF Server without config file

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?

Upvotes: 0

Views: 1027

Answers (1)

Jonathan Allen
Jonathan Allen

Reputation: 70307

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

Upvotes: 4

Related Questions