错误C#'system.stackoverflowexception' [英] Error C# 'system.stackoverflowexception'

查看:185
本文介绍了错误C#'system.stackoverflowexception'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

推荐答案

当你在堆栈上放太多时,你会得到一个堆栈溢出 - 每个线程一个内存存储方法返回地址和局部变量的区域,而不是存储对象实例的堆。堆栈相当大 - 溢出它不是正常现象。



因此,几乎唯一获得堆栈溢出的方法是直接或间接地通过从该方法中调用方法来使用递归。由于我们不知道代码是什么方法,因此您需要使用调试器在运行时跟踪该代码并找出递归发生的位置。然后你可以通过阻止无限循环来修复它(可能完全没有调用方法,相机警报不太可能需要递归)。
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).


这篇关于错误C#'system.stackoverflowexception'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆