Click here to Skip to main content
14,327,707 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have an  error "System.StackOverflowException"
 when I get all alarms from cameras devices, any help ??


What I have tried:

switch (_iAlarmType)
            {
                case AlarmConstMsgType.ALARM_VCA_INFO:

                    sbAlarmMsg.Append("- VCA");
                    int iChannelNumber = 0;
                    int iretu = NVSSDK.NetClient_GetChannelNum(_ulLogonID, ref iChannelNumber);
                    int channelCamera = iChannelNumber;
                    int int_rule = 0;
                    int iBufSiz = 80;
                    m_lpbuf = new NVS_FILE_LPBUF();

                    int iRetx = NVSSDK.NetClient_VCAGetAlarmInfo(_ulLogonID, _iAlarmState, ref m_lpbuf, iBufSiz);

                  try {
                        Console.WriteLine("Loading received alerts : " + m_lpbuf.m_iRuleID , "MyAlarm_NOTIFY_V4" + " " + DateTime.Today.ToString());
                        ObjLog.LoggerWritter("Loading received alerts : " + m_lpbuf.m_iRuleID + "  MyAlarm_NOTIFY_V4" + " " + DateTime.Today.ToString());
                        ObjLog.LoggerWritter("Loading  Alerts Rules : {" + m_lpbuf.m_iRuleID + "} MyAlarm_NOTIFY_V4" + " " + str_VCARules.ToString());

 
                        int  AlarmSentChannel = channelCamera;
                        int AlarmSentCustCompanyID = CustomerID;
                        string  AlarmSentDateIng = Convert.ToString(DateTime.Today);
                        string AlarmSentDescription = GetiAlarmType(_iAlarmType) + " - " + sbAlarmMsg.ToString();
                        int AlarmSentEstado = _iAlarmState;
                        string AlarmSentIDE = Convert.ToString(m_lpbuf.m_iID);// IPCustomer; // cantidadtrips++;
                        string AlarmSentrctTarget = "";
                        string AlarmSentRuleDescrip = GetiAlarmType(_iAlarmType) + " - " +  sbAlarmMsg.ToString();
                        int AlarmSentRuleID =  m_lpbuf.m_iRuleID; 
                        int AlarmSentState = _iAlarmState;
                        int AlarmSentTargetDirection = 0;
                        int AlarmSentTargetID = Convert.ToInt32(_iAlarmState.ToString());
                        int AlarmSentTargetSpeed = 0;
                        int AlarmSentTargetType = _iAlarmType;
                        int AlarmSentventType = _iAlarmType;

                        try
                        {
                            
                            string needle = _ulLogonID.ToString();
                            foreach (Device foo in Lista)
                            {
                                if (foo.DeviceIDLogon == needle)
                                {
                                    AlarmSentIDE = foo.DeviceIP;
                                }
                            }
                        }catch (Exception ex){

                        }

                        
                        SendAlarmsToNextivaSWG( AlarmSentChannel,
                                                AlarmSentCustCompanyID,
                                                AlarmSentDateIng,
                                                AlarmSentDescription,
                                                AlarmSentEstado,
                                                AlarmSentIDE,
                                                AlarmSentrctTarget,
                                                AlarmSentRuleDescrip,
                                                AlarmSentRuleID,
                                                AlarmSentState,
                                                AlarmSentTargetDirection,
                                                AlarmSentTargetID,
                                                AlarmSentTargetSpeed,
                                                AlarmSentTargetType,
                                                AlarmSentventType);

                        ObjLog.LoggerWritter("Sending received alerts to WebService Server from Device : " + AlarmSentIDE);

                   } catch (Exception ex) {
                            Console.WriteLine("Error Remote Windows Service SWG : {0} ", "MyAlarm_NOTIFY_V4" + " " + DateTime.Today.ToString());
                   }

                    return;
                  
                    break;
                default:
                    sbAlarmMsg.Append("-" + _iAlarmType.ToString());
                    break;
            }
Posted
Updated 20-Sep-17 8:01am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You get a stack overflow when you put too much on the stack - the one-per-thread memory area that stores method return addresses and local variables as opposed to the heap where your object instances are stored. And the stack is reasonably big - overflowing it is not a normal occurrence.

As a result, pretty much the only way to get a stack overflow is to use recursion, directly or indirectly by calling a method from within that method. Since we have no idea what method that code is inside, you will need to use the debugger to follow that code while it is running and find out where the recursion is happening. Then it's up to you to fix it by preventing the infinite loop (probably by not calling the method at all, it's unlikely that a camera alarm should need to be recursive).
   
Comments
Preatorian (RightCom) 20-Sep-17 14:08pm
   
Thank , i ll see your option

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100