zoukankan      html  css  js  c++  java
  • 修改config中的assemblyBinding

    修改config中的assemblyBinding

    未测试这段代码

    private void SetRuntimeBinding(string path, string value)
        {
            XmlDocument doc = new XmlDocument();
    
            try
            {
                doc.Load(Path.Combine(path, "MyApp.exe.config"));
            }
            catch (FileNotFoundException)
            {
                return;
            }
    
            XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
            manager.AddNamespace("bindings", "urn:schemas-microsoft-com:asm.v1");
    
            XmlNode root = doc.DocumentElement;
    
            XmlNode node = root.SelectSingleNode("//bindings:bindingRedirect", manager);
    
            if (node == null)
            {
                throw (new Exception("Invalid Configuration File"));
            }
    
            node = node.SelectSingleNode("@newVersion");
    
            if (node == null)
            {
                throw (new Exception("Invalid Configuration File"));
            }
    
            node.Value = value;
    
            doc.Save(Path.Combine(path, "MyApp.exe.config"));
        }

    -

  • 相关阅读:
    第 2 章 MySQL 架构组成
    MySql学习笔记
    大型项目成功的关键
    内连接区别外连接
    UML2.0
    软件架构师之路
    UVA
    ZOJ
    UVA
    UVA
  • 原文地址:https://www.cnblogs.com/runliuv/p/11653213.html
Copyright © 2011-2022 走看看