0

I have a WCF service -

public class DemoClass : IDemoClass
{

}

I can successfully host this WCF Service in another managed windows service. When the main service loads I start my WCF main service like this -

ServiceHost servHost = new ServiceHost(typeof(DemoClass));
servHost.Open();

I now want to be able to pass parameters to the WCF service when it starts so that I can pass something to it's constructor -

public class DemoClass
{        
   public DemoClass(string parameter)
   {
       //need to access the parameter value that is passed here.
   }
}

ServiceHost does not allow me to do that. How can I achieve this?

sandunes90
  • 355
  • 3
  • 16
  • another SO has answer: [ServiceHostFactory](http://stackoverflow.com/questions/2454850/how-do-i-pass-values-to-the-constructor-on-my-wcf-service/2455039#2455039) – Lei Yang Apr 25 '17 at 01:07
  • I am not sure of the context of the answer. Could you post a sample based on my code? – sandunes90 Apr 26 '17 at 00:14

0 Answers0