TargetInvocation Exception in C#

May 21, 2011 at 07:01:37
Specs: Windows XP
I am getting TargetInvocation Exception while running my code. I am working over Speech Recognition project. I am unable to find the cause behind it but I guess its because of the call to the speech handler. Following is the module.

recog.Enabled = true;
GrammarBuilder grammar = new GrammarBuilder();
grammar.Append(new Choices("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"backspace", "point", "equals", "plus", "minus", "multiplied by", "divided by", "LOAN"));
recog.LoadGrammar(new Grammar(grammar));
recog.SpeechDetected += recog_SpeechDetected;
recog.SpeechRecognized += recog_SpeechRecognized;
recog.SpeechRecognitionRejected += recog_SpeechRejected;
recog.SpeechHypothesized += recog_SpeechHypothesized;
// throw new TargetInvocationException("Inner Exception");
catch (Exception e)
//MessageBox.Show(" " +e.Message);
MessageBox.Show("Message: " + e.Message);
MessageBox.Show("Source: " + e.Source);
MessageBox.Show("Target: " + e.TargetSite);
MessageBox.Show("Stack: " + e.StackTrace);
It sometimes displays the stacktrace. Any suggestion will be appreciated.

See More: TargetInvocation Exception in C#

Report •

May 22, 2011 at 08:49:23
It sometimes displays the stacktrace.
What does that look like?

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question