Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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
Posted
Updated 14-Jul-16 22:36pm
v3
Comments
Richard Deeming 15-Jul-16 9:46am    
Removing the content of your question after it has been answered is extremely rude.

Use the debugger.
Set a breakpoint at the line:
C#
myMib.loadDirectoryMib(Environment.GetFolderPath(Environment.SpecialFolder.System ));
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.
 
Share this answer
 
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900