堆栈溢出异常未处理.. C#SNMP [英] Stack overflow exception unhandled.. C# SNMP

查看:95
本文介绍了堆栈溢出异常未处理.. C#SNMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助解决这个问题。我是这个C#的新手。对你的帮助表示感谢。这是一个用于获取应用SNMP的网络系统的MIB值的程序。我得到的值很少,但随后返回此错误。





发生了'System.StackOverflowException'类型的未处理异常在mscorlib.dll中显示在行

Can anyone please help get through this problem. I am new to this C#. Your help will be greatly appreciated. This is a program for getting the MIB values of a networking system which applies SNMP. I am getting few values, but then returning back with this error.


"An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll" is showing in line

推荐答案

使用调试器。

在行处设置断点:

Use the debugger.
Set a breakpoint at the line:
myMib.loadDirectoryMib(Environment.GetFolderPath(Environment.SpecialFolder.System ));

然后进入你的方法。

关注代码一步一步,看看它在做什么。

最可能的事情是它试图递归加载文件,并且递归没有被终止 - 这会破坏堆栈,你得到了例外。

我们不能为你做到这一点:我们没有你的 Mib 类或你的Windows文件夹:heck我们甚至不知道你正在运行什么版本的Windows!

所以试一试,看看你的 loadDirectoryMib 方法开始重新开始诅咒。

And step into your method.
Follow the code through step by step, and see what it is doing.
The most likely thing is that it's trying to recursively load files, and that the recursion isn't being terminated - which blow out the stack, and you get the exception.
We can't do that for you: we don't have your Mib class or your Windows folder: heck we don't even know what version of Windows you are running!
So give it a try, and see where your loadDirectoryMib method starts to recurse.


你应该学会尽快使用调试器。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到它有一个停止做你期望的点。

调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - A初学者指南 [ ^ ]



通常,问题来自您的代码以递归方式调用自身并且无法返回。结束条件通常是错误的。
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

Usually, the problem comes from your code calling itself in a recursive fashion and failing to return. the end condition is usually wrong.


这篇关于堆栈溢出异常未处理.. C#SNMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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