我創建了一個WCF服務庫。然後我創建了一個Windows服務來承載這個WCF服務。 現在我想在同一個窗口服務中調用WCF服務庫中定義的函數。創建WCF服務,託管在窗口服務中,嘗試在該服務中使用。怎麼做?
protected override void OnStart(string[] args)
{
if (serviceHost != null)
serviceHost.Close();
// Create a ServiceHost for the Registration type and
// provide the base address.
serviceHost = new System.ServiceModel.ServiceHost(typeof(Registration));
// Open the ServiceHostBase to create listeners and start
// listening for messages.
serviceHost.Open();
Registration r = new Registration();
System.Threading.Thread t = new System.Threading.Thread(r.ReadAttempt);
Object passParameterToCallback = null;
t.IsBackground = false;
t.Start(passParameterToCallback);
}