I writing WCF application which are hosted in windows service using WCF WEB API. The problem is that I would like to pass to service class reference to my hosting application.
Below the Host code:
Dim t1 As System.Type = GetType(MOMRESTService.Service)
' Create a new ServiceHost to start and stop the service
Dim serviceHost1 As New System.ServiceModel.ServiceHost(t1, New System.Uri(addressRoot)) ' for MEX inquiries
' Create the REST binding
Dim restBinding As New System.ServiceModel.WebHttpBinding()
' Create the REST endpoint. We need to do this explicitly in order to add a custom behavior to it.
Dim restEndPoint = New System.ServiceModel.Description.ServiceEndpoint(System.ServiceModel.Description.ContractDescription.GetContract(GetType(MOMRESTService.IService)), restBinding, New System.ServiceModel.EndpointAddress(addressRoot))
' Add a customm behavior to the REST endpoint
' Add the endpoint to the service
' Open the ServiceHost to create listeners and start listening for messages
Below Service code:
Public Function EchoWithGet(s As String) As String Implements IService.EchoWithGet
Return "You said " & s
So I would like in service method "EchoWithGet" raise event to Hosted application. In another words I need to have reference from service to hosted application or to an object which can be passed from hosted application to service.
We tried to use singleton and created constructor in service, but it use sigle thread for all incoming request and we need multithreaded application.
With Rest API it also only using InstanceContextMode.Single:
var instance =
Is exist any way to solve my problem?