Cannot evaluate expression because the current thread is in a stack overflow state" at the commented line

StackOverflow https://stackoverflow.com/questions/23535069

  •  17-07-2023
  •  | 
  •  

質問

I created a c# SNMP application using the SNMP library.

But then I get an error "Cannot evaluate expression because the current thread is in a stack overflow state" at the commented line.

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

this codes declare the args variable:

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;
    }

when I debug by line, the args[] passed as:

[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"
役に立ちましたか?

解決

One of the possible reasons can be infinite loop somewhere in UdpAddress constructor. Could you show what's in UdpAddress constructor?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top