1
[WCF新手]
我有一個基本的客戶端服務器WCF項目。
我的服務是「gui」less應用程序,這意味着我創建了winform應用程序,刪除了Form1.cs和啓動gui的行。
該服務運行正常,我正在使用servicehost.open ..
我的問題是,它是「串行」(同步),所以在一秒鐘後應用程序存在。
如何讓應用程序保持活動狀態並監聽主機?
我需要暫停該進程,然後在我想結束時訪問host.close。 感謝WCF服務應用程序沒有gui,將保持活着
這是我們的服務代碼:
class Program
{
public static Uri BaseAddress;
[STAThread]
static void Main(string[] args)
{
string baseAddressStr = "http://localhost:7000/someservice";
BaseAddress = new Uri(baseAddressStr);
using (ServiceHost host = new ServiceHost(typeof(MyClass)BaseAddress))
{
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb);
host.Open();
host.Close();
}
}
}
感謝您的回答,現在它的無情,後來它將是wpf gui。我現在只需要(真) – ilansch 2013-03-18 10:37:42