自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

WCF服務(wù)啟動(dòng)特殊方法分享

開發(fā) 開發(fā)工具
我們在這篇文章中為大家介紹的WCF服務(wù)啟動(dòng)的方法,主要就是不通過配置文件來進(jìn)行啟動(dòng)。那么具體的操作方法將會(huì)在這里做一個(gè)詳細(xì)介紹。

對于WCF服務(wù)啟動(dòng)的方法,我們可以通過多種方式來實(shí)現(xiàn)。在這里我們將會(huì)通過一種特殊的方法來實(shí)現(xiàn)WCF服務(wù)啟動(dòng)。大家首先可以通過一段代碼示例來詳細(xì)分析一下這一服務(wù)的啟動(dòng)方法,以此加深這方面的印象。

WCF服務(wù)啟動(dòng)代碼示例:

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.ServiceModel;  
  6. using System.ServiceModel.Description;  
  7. namespace WCF1  
  8. {  
  9. [ServiceContract(Name = "MyService"Namespace = 
    "http://www.huisoftware.com")]  
  10. public class MyService  
  11. {  
  12. [OperationContract]  
  13. public string MyMethod(string str)  
  14. {  
  15. return str + "Server Hello World";  
  16. }  
  17. }  
  18. class Program  
  19. {  
  20. static void Main(string[] args)  
  21. {  
  22. using (ServiceHost host = new ServiceHost(typeof(MyService)))  
  23. {  
  24. host.AddServiceEndpoint(typeof(MyService), new WSHttpBinding(), 
    "http://127.0.0.1:8080/MyService");  
  25. if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null)  
  26. {  
  27. ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();  
  28. behavior.HttpGetEnabled = true;  
  29. behavior.HttpGetUrl = new Uri("http://127.0.0.1:8080
    /MyService/metadata");  
  30. host.Description.Behaviors.Add(behavior);  
  31. }  
  32. host.Opened += delegate  
  33. {  
  34. Console.WriteLine("WCF服務(wù)已經(jīng)啟動(dòng)");  
  35. };  
  36. host.Open();  
  37. Console.Read();  
  38. }  
  39. }  
  40. }  

WCF服務(wù)啟動(dòng)的相關(guān)代碼就為大家介紹到這里。

【編輯推薦】

  1. WCF依賴屬性具體概念詳解
  2. WCF跨域具體問題解析
  3. WCF消息交換應(yīng)用方式技巧分享
  4. WCF會(huì)話狀態(tài)功能特點(diǎn)解析
  5. WCF綁定元素具體應(yīng)用知識介紹
責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2009-12-22 19:00:08

WCF回調(diào)

2009-12-22 13:48:09

引用WCF服務(wù)

2010-02-24 11:22:04

WCF方法重載

2010-03-02 13:54:43

WCF控制服務(wù)對象釋放

2009-12-22 15:14:33

WCF調(diào)用

2010-03-01 09:48:23

WCF會(huì)話服務(wù)

2010-02-25 10:52:29

WCF響應(yīng)服務(wù)

2009-12-21 13:27:45

WCF服務(wù)配置信息

2010-03-02 17:35:20

WCF服務(wù)加載

2010-02-26 16:05:14

寄宿WCF服務(wù)

2009-12-22 16:03:03

WCF異常

2009-12-22 19:26:51

WCF綁定

2010-02-24 09:59:19

WCF服務(wù)異步代理

2010-03-01 17:44:39

Silverlight

2009-11-06 09:48:40

WCF服務(wù)

2010-02-22 17:58:06

WCF異步上傳

2010-03-01 13:06:49

WCF繼承

2010-02-25 16:52:12

引用WCF服務(wù)

2010-01-21 15:56:31

VB.NET文本框

2010-02-26 14:12:27

WCF元數(shù)據(jù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號