Help me iam getting stack overflow exeception , while my solution build successfully , but it threw the stack overflow error
-
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
-
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
Take a close look to your code:
Label_0104:
foreach (Character character in this.charSet)///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
} -
Take a close look to your code:
Label_0104:
foreach (Character character in this.charSet)///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
} -
Take a close look to your code:
Label_0104:
foreach (Character character in this.charSet)///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}sir, Thanks for your suggestions, but what is wrong the for each loop , iam not getting as it will For each Character in this charset, as iam getting all the values in the charaset, iam able to initalize the characters in charset, but during looping only iam getting error Am i using wrong method of looping foe each values or it is wrong way of using loop,please tell me the alternate to acheive this with regards Radhika
-
means wat sir, iam not getting wat your telling , if you could suggest any solution for it , it would be grt help of yours
-
sir, Thanks for your suggestions, but what is wrong the for each loop , iam not getting as it will For each Character in this charset, as iam getting all the values in the charaset, iam able to initalize the characters in charset, but during looping only iam getting error Am i using wrong method of looping foe each values or it is wrong way of using loop,please tell me the alternate to acheive this with regards Radhika
I never use goto to exit a loop ....
-
sir, Thanks for your suggestions, but what is wrong the for each loop , iam not getting as it will For each Character in this charset, as iam getting all the values in the charaset, iam able to initalize the characters in charset, but during looping only iam getting error Am i using wrong method of looping foe each values or it is wrong way of using loop,please tell me the alternate to acheive this with regards Radhika
To elaborate on what Thomas said: take a look at your code:
Label_0104:
foreach (Character character in this.charSet) ///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}So, you enter the first loop, enter the second, then when you find a match with class2, you go back to before the first loop and enter again. How are you ever going to to get out of the loop? No wonder you run out of memory first!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
There is a commonly accepted statement that "
goto
is evil". That my be a little extreme, but if it is to be used, it should be done with GREAT caution. There are very few cases where goto is the best way to control program flow in modern day languages. Rewrite the code without using any goto(s) (and preferably with more descriptive variable naming) and it will be much easier to follow - and will most likely work!Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
Label_0104:
foreach (Character character in this.charSet)
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}Stack overflows are often caused by an infinite loop in the code and that's what you have here. When the condition character.type == class2 is true the outer loop restarts and then when the same condition is encountered for a second time, the loop restarts, and so on. I haven't read your code fully but I suspect that you meant to jump to a point after the end of the outer loop, not just before it's start. Alan.
-
I never use goto to exit a loop ....
Ok sir then wat else u use to exit the loop , my problem is that it gives me error only in the For each loop syntax for this.charset statement, so i will try to resolve it but also suggest ur view wat should i use to exit the loop your suggestions are really very helpful thanks alot sir for your kind suggestions with regards radhika
-
Ok sir then wat else u use to exit the loop , my problem is that it gives me error only in the For each loop syntax for this.charset statement, so i will try to resolve it but also suggest ur view wat should i use to exit the loop your suggestions are really very helpful thanks alot sir for your kind suggestions with regards radhika
loops are best exited with
break
. If you need to know if some condition was met inside the loop, create a variable outside the loop and set it's value before calling break. You can then check that variable after the loop has completed or been broken out of.Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
radhikasharma wrote:
Label_0104: foreach (Character character in this.charSet)///Error of stack overflow execption in Charset// { foreach (CharClass class2 in classArray) { if (character.type == class2) { num17++; goto Label_0104; } } }
What's that dude ????? Are you trying to live in danger ????? If I close my eyes to the ultimate sin (aka goto) the whole situation smells like an eternal loop.
-
radhikasharma wrote:
Label_0104: foreach (Character character in this.charSet)///Error of stack overflow execption in Charset// { foreach (CharClass class2 in classArray) { if (character.type == class2) { num17++; goto Label_0104; } } }
What's that dude ????? Are you trying to live in danger ????? If I close my eyes to the ultimate sin (aka goto) the whole situation smells like an eternal loop.
Thanks for your response sir , please tell me the solution and wat iam doing wrong in the for each loop please suggest me the right code so that i will not get any stack overflow exception error also suggest any solution for the above error with regards radhika
-
Thanks for your response sir , please tell me the solution and wat iam doing wrong in the for each loop please suggest me the right code so that i will not get any stack overflow exception error also suggest any solution for the above error with regards radhika
Get rid of these goto statements. They produce the stack overflow. Goto is a relic in modern languages . Use a break statement as mentioned by many other people to exit the loop. Avoid by any means to use goto statements.
-
Get rid of these goto statements. They produce the stack overflow. Goto is a relic in modern languages . Use a break statement as mentioned by many other people to exit the loop. Avoid by any means to use goto statements.
How do you keep a Aggie busy? Write 'Please turn over' on both sides of a piece of paper.
-
Get rid of these goto statements. They produce the stack overflow. Goto is a relic in modern languages . Use a break statement as mentioned by many other people to exit the loop. Avoid by any means to use goto statements.
Thanks alot sir ,my problem is solved iam very much greatful to you with regards radhika
-
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
-
Where are the
num12
,num14
,num20
,num22
andnum24
variables? :doh:Greetings - Jacek Gajek
My guess is someone elses DLL was disassembled.
-
My guess is someone elses DLL was disassembled.
It does look like the output from Reflector when used on a .net assembly, that was built in release mode, with the "Optimize code" box checked. Maybe he should contact the person that wrote the original code to start with, and get the real, (hopefully commented) source. And hope that source isn't copyrighted....
-
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code: code 1. private void InitializeCharacters(InkOverlay inkOverlay) { this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden)); this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol)); this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation)); this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number)); this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number)); this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number)); this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number)); this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number)); this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number)); this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number)); this.Add(new Characte
Hi radhika! Sorry it's a little late for this reply, but when I looked at your code I nearly cried. I think your problem is solved, so some other suggestions: * Invest some time in learning the basics of the environment and language you are using. (I think you are new to programming) So you learn what type of errors can cause something like StackOverflowException. * Thinking about good variable names is never wasted time. * Posts on any programming forum should never be in the style "I don't understand what you are talking about - just give me the solution" * If something compiles it doesn't mean that it is free of errors - NEVER! It just means it's free of syntax-errors. * If you have written such a long method - think about how to optimize: code length (maybe split into several methods), readability (naming, comments, whitespace), functionality... * Next time you want to use goto: leave it! Another thing: Maybe you had some reason for all your Add(...Character(...)) lines but to me it looks very strange: what about:
for(char ch = (char) 0; ch < 128; ch++) { // do something with char }
:rose: