C# .NET - Error while open and close a form

Asked By Prakhar
05-Sep-10 03:30 AM
//Here is the code for first page :-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Recognition;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
      public Form1()
      {
        InitializeComponent();
      }
    
      
      private void Form1_Load(object sender, EventArgs e)
      {
        SpeechRecognizer sp = new SpeechRecognizer();
        Choices m = new Choices();
        m.Add("next");
        GrammarBuilder gb = new GrammarBuilder();
        gb.Append(m);
        Grammar g = new Grammar(gb);
        sp.LoadGrammar(g);
        sp.SpeechRecognized+=new EventHandler<SpeechRecognizedEventArgs>(sp_SpeechRecognized);
      }
      void sp_SpeechRecognized(object sender,  SpeechRecognizedEventArgs e)
      {
        if (e.Result.Text == "next")
        {
          button1.PerformClick();
        }
      }

      private void button1_Click(object sender, EventArgs e)
      {
        Form2 f2 = new Form2();
        f2.Show();
      }
    }
}
//Here is code for next form :-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Recognition;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
      public Form2()
      {
        InitializeComponent();
      }

      private void Form2_Load(object sender, EventArgs e)
      {
        SpeechRecognizer spr = new SpeechRecognizer();
        Choices m = new Choices();
        m.Add("back");
        GrammarBuilder gb = new GrammarBuilder();
        gb.Append(m);
        Grammar g = new Grammar(gb);
        spr.LoadGrammar(g);
        spr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(spr_SpeechRecognized);
      }
      void spr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
      {
        if (e.Result.Text == "back")
        {
          button1.PerformClick();
        }
        
      }

      private void button1_Click(object sender, EventArgs e)
      {
        Form1 f = new Form1();
        f.Show();
      }
    }
}
//But when we debug it, then it shows error as a exception. What is solution????
  Shunmuga Nathan replied to Prakhar
05-Sep-10 01:11 PM
Can you tell me, Actual error message you are receiving
  Prakhar replied to Shunmuga Nathan
07-Sep-10 02:45 AM
Actual error message is exception of type " refraction or Target " in application form while running form1.......
Create New Account
help
Error Handling in a called function Hi Guys, A quick question for you. I have a Sub which calls a Function several times. Both the Sub & Function have error handling. The problem is, when there is an error in the called Function, the calling Sub Error Handler fires. How can I get the Function Error Handler to fire? Cheers Pete You can return a boolean from the Function to indicate whther it was successful. For example: Private Sub SendTrades() On Error GoTo Err_Handler 'do some stuff If EmailTrades(parameters) Then 'Do more stuff. . . . Else MsgBox "Problem Description Resume Err_Resume End Sub Public Function EmailTrades(ByVal parameters as blah) As Boolean On Error GoTo Err_Handler 'do some emailing stuff. If it fails here, the function will return false will help you. Hi Vickey, Thanks for the speedy reply. In the function where the error occurs, I don't want it to return a boolean and exit. There is other
will help you Hi I am getting the following message at the time of compilation Error 52 The install location for prerequisites has not been set to 'component vendor's web framework files in the Application folder of setup project ? But I am getting the following error messages when compiling the setup project Error 1 The install location for prerequisites has not been set to 'component vendor's web on disk. See Help for more information. H: \ SOURCES \ IMPEX SETUP \ IMPEXSETUP \ IMPEXSETUP.vdproj IMPEXSETUP Error 2 The install location for prerequisites has not been set to 'component vendor's web on disk. See Help for more information. H: \ SOURCES \ IMPEX SETUP \ IMPEXSETUP \ IMPEXSETUP.vdproj IMPEXSETUP Error 3 The install location for prerequisites has not been set to 'component vendor's web on disk. See Help for more information. H: \ SOURCES \ IMPEX SETUP \ IMPEXSETUP \ IMPEXSETUP.vdproj IMPEXSETUP Error 4 The install location for prerequisites has not been set to 'component vendor's web on disk. See Help for more information. H: \ SOURCES \ IMPEX SETUP \ IMPEXSETUP \ IMPEXSETUP.vdproj IMPEXSETUP Error 5 The install location for prerequisites has not been set to 'component vendor's web on disk. See Help for more information. H: \ SOURCES \ IMPEX SETUP \ IMPEXSETUP \ IMPEXSETUP.vdproj IMPEXSETUP Error 6 The install location for prerequisites has not been set to 'component vendor's web
Web config error message When I try to open up a dotnetnuke site I get this error message: Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Unrecognized configuration section 'connectionStrings' Source Error: Line 15: < / sectionGroup> Line 16: < / configSections> Line 17: <connectionStrings> Line 18: <!- - Connection String for SQL disk but can neither access it or save data on it. I added it same error message: Configuration Error Description: An error occurred during the processing of a configuration file required
name = microsoft sam").Item(0); } catch (Exception ex) { throw ex; } } } } You can use the System.Speech.Recognition namespace to do this. . .with some limitations. Add System.Speech (should be in the GAC) to your project. Here's some sample code for a WinForms app: public partial class Form1 : Form { SpeechRecognizer rec = new SpeechRecognizer(); public Form1() { InitializeComponent(); rec.SpeechRecognized + = rec_SpeechRecognized; } void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { lblLetter.Text = e.Result.Text; } void Form1_Load(object sender, EventArgs e) { var c = new Choices(); for (var i = 0; i < = 100; i++) c.Add(i.ToString()); var gb = new GrammarBuilder(c); var g = new Grammar(gb); rec.LoadGrammar(g); rec.Enabled = true; } This recognizes the the form. You'll need a form with a label called lblLetter on it. System.Speech only works with a pre-defined list of words or phrases; it's not exactly seem to be a "download and play around with it" option. :( As for text-to-speech, System.Speech.Synthesis does this. It's even easier than the speech recognition. I wrote