成人免费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-24 11:22:04

WCF方法重載

2010-02-25 15:25:19

WCF通道

2009-12-22 19:00:08

WCF回調

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-03-01 17:39:07

WCF Address

2010-02-25 10:52:29

WCF響應服務
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美精产国品一二三区 | 91免费看片| 亚洲免费在线视频 | 国产激情在线 | 免费一二区 | 亚洲国产精品久久久久婷婷老年 | 日本人做爰大片免费观看一老师 | 涩涩鲁亚洲精品一区二区 | 日韩中出 | 中文字幕第一页在线 | 91免费电影| 国产一区 在线视频 | 玖玖在线免费视频 | 91精品国产91久久久久久吃药 | 午夜欧美一区二区三区在线播放 | 国产精品亚洲成在人线 | 免费观看av网站 | 欧美色人 | 看片天堂| 国产99久久精品一区二区300 | 日韩三级电影在线看 | 99国产精品视频免费观看一公开 | 久久亚洲高清 | 在线久草 | 亚洲一区二区三 | 91精品国产777在线观看 | 久久精品免费看 | 亚洲精品视频三区 | 国产欧美在线播放 | 蜜臀久久99精品久久久久野外 | 亚洲欧美久久 | 欧美久久视频 | 日本视频一区二区 | 日日噜噜噜夜夜爽爽狠狠视频, | 黄色一级免费 | 成人国产一区二区三区精品麻豆 | 欧美精品一区二区三区四区 在线 | 国产欧美一级二级三级在线视频 | 国产一区二区精品在线 | 日韩精品一区二区三区视频播放 | 黄免费观看视频 |