在 System.InvalidOperationException 中第一次偶然出现的“mscorlib.dll”类型的异常请问这是什么原因啊? #region URL入队列
        // push uri to the queue
        bool EnqueueUri(MyUri uri, bool bCheckRepetition)
        {
            // add the uri to the binary tree to check if it is duplicated or not
            if (bCheckRepetition == true && AddURL(ref uri) == false)
                return false;            Common comm = new Common();
            if (!(comm.ChoseJobUri(ref uri, "//JobWeb")))
                return false;            Monitor.Enter(queueURLS);
            try
            {
                // add the uri to the queue
                queueURLS.Enqueue(uri);
            }
            catch (Exception)
            {
            }
            Monitor.Exit(queueURLS);            return true;
        }
        #endregion我就在上面代码内加了一段代码:Common comm = new Common();
            if (!(comm.ChoseJobUri(ref uri, "//JobWeb")))
                return false;
请大年们帮忙,谢谢!

解决方案 »

  1.   


    public bool ChoseJobUri(ref MyUri uri, string xpath)
            {
                bool btn = false;
                XmlHelper xmlHelper = new XmlHelper();
                XmlNode node = xmlHelper.GetNode("EncodingType.xml", xpath);
                switch (uri.Host)
                {
                    case "www.tianjihr.com":
                        string url = node.ChildNodes[5].InnerText;
                        string param = node.ChildNodes[3].InnerText;
                        uri = new MyUri(url + param);//返回的URI
                        Hashtable ht = new Hashtable();
                        ht.Add("param", int.Parse(param) + 1);
                        xmlHelper.UpdateNode("EncodingType.xml", "Web", null, ht);//更新参数值
                        btn = true;
                        break;
                    default:
                        break;
                }
                return btn;
            }谢谢
      

  2.   

    请对一下代码段套上 try catch 应该是在读取分析xml文件是遇到的异常            XmlNode node = xmlHelper.GetNode("EncodingType.xml", xpath);
                switch (uri.Host)
                {
                    case "www.tianjihr.com":
                        string url = node.ChildNodes[5].InnerText;
                        string param = node.ChildNodes[3].InnerText;
                        uri = new MyUri(url + param);//返回的URI
                        Hashtable ht = new Hashtable();
                        ht.Add("param", int.Parse(param) + 1);
                        xmlHelper.UpdateNode("EncodingType.xml", "Web", null, ht);//更新参数值
                        btn = true;
                        break;
                    default:
                        break;
                }
      

  3.   

    我发现当另一个进程经过这句:XmlNode node = xmlHelper.GetNode("EncodingType.xml", xpath);
    就提示:由于以前的函数求值超时,函数求值被禁用。必须继续执行才能重新启用函数求值。
      

  4.   

    那继续贴 XmlHelper.GetNode方法吧
      

  5.   


    public XmlNode GetNode(string XmlFile, string nodePath)
            {
                XmlDocument xml = new XmlDocument();
                xml.Load(XmlFile);
                XmlNode xmlNode = xml.DocumentElement.SelectSingleNode(nodePath);
                return xmlNode;
            }我感觉这没有啥问题
      

  6.   

    对 ChoseJobUri 上个锁,保证其处是单线程运行的,试试