Monday, April 11, 2011

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?

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

0 comments:

Post a Comment