成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

WCF修改App.config配置文件技巧分享

開發 開發工具
WCF修改App.config配置文件的正確操作方法只要按照我們給出的這樣一段代碼來進行操作就能夠順利完成。大家可以以此為參考學習對象。

WCF對App.config配置文件的修改方法我們將會通過以下這段代碼為大家詳細介紹相關操作方法。希望對于又需要的朋友們能夠從今天介紹的內容中獲得一些幫助,來解決他們在實際應用中碰到的一些問題。

WCF修改App.config配置文件代碼示例:

  1. using System.ServiceModel.Configuration;using System.Text.
    RegularExpressions;// 修改配置文件  
  2. private void ChanageConfig()  
  3. {  
  4. Configuration config = ConfigurationManager.OpenExeConfiguration
    (Application.ExecutablePath);  
  5. ConfigurationSectionGroup sct = config.SectionGroups
    ["system.serviceModel"];  
  6. ServiceModelSectionGroup serviceModelSectionGroup = 
    sct as ServiceModelSectionGroup;  
  7. ClientSection clientSection = serviceModelSectionGroup.Client;  
  8. foreach (ChannelEndpointElement item in clientSection.Endpoints)  
  9. {  
  10. string pattern = "://.*/";  
  11. string address = item.Address.ToString();  
  12. string replacement = string.Format("://{0}:{1}/", 
    Global.ServerIP, Global.ServerPort);  
  13. address = Regex.Replace(address, pattern, replacement);  
  14. item.Address = new Uri(address);  
  15. }  
  16. config.Save(ConfigurationSaveMode.Modified);  
  17. ConfigurationManager.RefreshSection("system.serviceModel");  
  18. return;  
  19. /*  
  20. Configuration configuration = ConfigurationManager.
    OpenExeConfiguration(ConfigurationUserLevel.None);  
  21. ServiceModelSectionGroup serviceModelSectionGroup = 
    ServiceModelSectionGroup.GetSectionGroup(configuration);  
  22. ClientSection clientSection = serviceModelSectionGroup.Client;  
  23. foreach(ChannelEndpointElement item in clientSection.Endpoints)  
  24. {  
  25. MessageBox.Show(item.Address.Host);  
  26. }  
  27. configuration.Save();  
  28. */  
  29. return;  
  30. XmlDocument xmlDoc = new XmlDocument();  
  31. xmlDoc.Load("Rca.exe.config");  
  32. XmlNodeList nodeList = xmlDoc.SelectSingleNode
    ("configuration/appSettings").ChildNodes;  
  33. foreach (XmlNode node in nodeList)  
  34. {  
  35. switch (node.Attributes["key"].InnerText.ToLower())  
  36. {  
  37. case "serverip":  
  38. node.Attributes["value"].InnerText = Global.ServerIP;  
  39. break;  
  40. case "serverport":  
  41. node.Attributes["value"].InnerText = Global.ServerPort;  
  42. break;  
  43. case "langdataid":  
  44. node.Attributes["value"].InnerText = Global.LangDataID;  
  45. break;  
  46. case "uidataid":  
  47. node.Attributes["value"].InnerText = Global.UIDataID;  
  48. break;  
  49. }  
  50. }  
  51. nodeList = xmlDoc.SelectSingleNode("configuration/
    system.serviceModel/client").ChildNodes;  
  52. foreach (XmlNode node in nodeList)  
  53. {  
  54. string pattern = "://.*/";  
  55. string address = node.Attributes["address"].InnerText;  
  56. string replacement = string.Format("://{0}:{1}/", 
    Global.ServerIP, Global.ServerPort);  
  57. address = Regex.Replace(address, pattern, replacement);  
  58. node.Attributes["address"].InnerText = address;  
  59. if (node.Attributes["contract"].InnerText == "LogicCommon")  
  60. {  
  61. LogicCommonCfgName = node.Attributes["name"].InnerText;  
  62. LogicCommonAddress = node.Attributes["address"].InnerText;  
  63. }  
  64. }  
  65. xmlDoc.Save("Rca.exe.config");  

以上就是我們為大家介紹的WCF修改App.config配置文件的全部操作步驟。

【編輯推薦】

  1. WCF openation實際應用異常解決方案
  2. MSMQ使用WCF正確實現技巧講解
  3. WCF PreSession模式保持調用狀態
  4. WCF PreCal模式基本代碼示例解析
  5. WCF使用Nhibernate具體操作步驟圖解
責任編輯:曹凱 來源: 博客園
相關推薦

2009-12-21 11:19:50

WCF配置文件

2010-02-23 14:17:20

WCF配置文件

2009-08-24 17:20:34

C#項目實例

2010-02-22 10:18:18

WCF配置文件

2025-02-10 00:55:00

2009-11-05 10:30:41

WCF Address

2010-02-22 17:58:06

WCF異步上傳

2010-03-01 13:06:49

WCF繼承

2009-12-21 13:06:05

WCF Address

2009-11-09 13:31:09

WCF服務端配置

2021-08-13 13:55:03

鴻蒙HarmonyOS應用

2010-02-22 15:20:54

WCF WS-Disc

2010-02-22 17:21:02

WCF消息交換

2010-02-26 14:12:27

WCF元數據

2010-02-23 16:46:47

WCF并發能力

2010-02-24 11:22:04

WCF方法重載

2010-02-25 15:25:19

WCF通道

2009-12-22 19:00:08

WCF回調

2010-03-01 17:39:07

WCF Address

2010-02-23 13:03:34

WCF序列化
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产高清视频在线观看 | 国产欧美一级 | 成年人免费看的视频 | 一级免费看 | 欧美日韩高清在线观看 | 亚洲精品免费视频 | 亚洲人久久 | 久久久久久国模大尺度人体 | 日韩一区二区精品 | 国产伦精品一区二区三区照片91 | 亚洲精品一区二区三区丝袜 | 国产在线高清 | 在线播放一区二区三区 | 国产精品三级久久久久久电影 | 日本一区二区在线视频 | 免费午夜视频在线观看 | 日韩精品在线一区 | 日日干天天干 | 欧美成人影院 | 欧美一卡二卡在线观看 | 国产精品一区在线观看 | 日本久久福利 | 国产91观看 | 色综合久 | 欧美 日韩 在线播放 | 91精品一区二区三区久久久久 | 日日天天| 97久久精品午夜一区二区 | 成人免费视频观看视频 | 亚洲h色| 天堂在线91 | 欧美黑人一级爽快片淫片高清 | 99热激情 | 久草在线 | 亚洲深夜福利 | 精品少妇一区二区三区在线播放 | 亚洲va在线va天堂va狼色在线 | av在线免费网 | 国产精品极品美女在线观看免费 | 黄色免费观看网站 | 国产ts人妖系列高潮 |