2009-02-17 60 views
4

我剛剛創建了一個WCF服務,this MSDN tutorial如何在Visual Studio之外啓動WCF服務?

    從Visual Studio中
  • 我可以CTRL-F5所以它運行
  • 然後我就可以開始我的控制檯應用程序客戶端和消費服務沒有問題

現在我要開始我的服務服務OUTSIDE視覺工作室並讓不同的客戶使用它。

但是當我去命令行並執行這個文件../bin/Debug/testService.exe時,我得到一個異常:「輸入格式錯誤」。

我得到同樣的錯誤,當我發佈服務,並開始發佈的.exe文件。

我在這裏錯過了什麼?我是否需要發送Visual Studio發送的某種參數以使其運行?

我如何外部運行我的WCF服務的Visual Studio之外?

回答

0

對我來說,有人展示如何獲取WCF應用程序啓動和運行,所以你可以學習的是手動創建這一切,避開內置工具VS2008的最簡單的方法。這裏是一個很好的教程將告訴您該怎麼做:

WCF the Manual Way - the Right Way

我寫了一篇文章關於該條擴大一點點在我的博客文章。我包括源​​文件以及屏幕錄像。你可以在這裏找到它:

Manual WCF - An Extension

此外,一個優秀的系列教程可以在米歇爾布斯塔曼特的Learning WCF被發現。這有點過時了,主要關注.NET 3.0,但大多數示例仍然有效,她在她的博客上更新了她的源代碼。

0
Uri baseAddress = new Uri("http://localhost:8080/hello"); 

// Create the ServiceHost. 
using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress)) 
{ 
    // Enable metadata publishing. 
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
    smb.HttpGetEnabled = true; 
    smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; 
    host.Description.Behaviors.Add(smb); 

    // Open the ServiceHost to start listening for messages. Since 
    // no endpoints are explicitly configured, the runtime will create 
    // one endpoint per base address for each service contract implemented 
    // by the service. 
    host.Open(); 

    Console.WriteLine("The service is ready at {0}", baseAddress); 
    Console.WriteLine("Press <Enter> to stop the service."); 
    Console.ReadLine(); 

    // Close the ServiceHost. 
    host.Close(); 
} 

http://msdn.microsoft.com/en-us/library/ms731758%28v=vs.110%29.aspx