I am having a problem creating a WCF service instance with a parameter. The situation is inside the service call I am unable to create a third-parth library COM object (there is some threading issue and this object can only be created in the main thread). As a result, I want to simply maintain a list of objects to be created inside the service function, and let the main thread do the actual object creating work.
But I am not clear how I can simply pass the list to the constructor of service instance. As little as I know of WCF, I think the service instance is created by the framework itself and it doesn’t take any parameter in the constructor. So what is the simplest way to pass this list from main thread to service instance? Thanks!
Try to play with:
System.ServiceModel.ServiceHostSystem.ServiceModel.Activation.ServiceHostFactoryServiceBehavior.InstanceContextMode:InstanceContextMode.Single, etc.Class-scope fields:
It will be instantiated before default constructor call, or anyway if you don’t have a default one