无法计算表达式,因为当前线程处于堆栈溢出状态"在注释行



我使用SNMP库创建了一个c# SNMP应用程序。

但随后我得到一个错误"不能评估表达式,因为当前线程处于堆栈溢出状态"在注释行。

try
        {
            UdpAddress udp = new UdpAddress(args[1]); //error occur at this line
            SnmpVersion ver = SnmpVersion.SNMPv1;
            //some other snmp codes
        }

这个代码声明了args变量:

public Hashtable getValues(SNMPObject[] SNMPObjects)
    {
        int nbrArgs = 5 + 2 * SNMPObjects.Length;
        string[] args = new string[nbrArgs];
        args[0] = "get";
        args[1] = this.getIPAddress();
        args[2] = "-Dl0"; //don't make debug
        args[3] = "-c" + this.getCommunityRead(); //community read
        args[4] = "-C" + this.getCommunityWrite(); //community write
        int i = 5;
        foreach (SNMPObject mySNMPObject in SNMPObjects)
        {
            args[i] = "-o";
            args[i + 1] = mySNMPObject.getOID();
            i = i + 2;
        }
        //lancer la requête
        Hashtable htResult = Manager.makeOrder(args);
        return htResult;
    }

当我按行调试时,参数[]传递为:

[0] = "get"  
[1] = "10.0.0.120"  
[2] = "-Dl0"  
[3] = "-cpublic"  
[4] = "-Cpublic"  
[5] = "-o"  
[6] = "1.3.6.1.2.1.1.5.0"  
[7] = "-o"  
[8] = "1.3.6.1.2.1.2.2.1.16.1"

一个可能的原因是在UdpAddress构造函数中的某个地方存在无限循环。你能展示一下UdpAddress构造函数里有什么吗?

最新更新