locked
Compiler Error CS0103: The name ' ' does not exist in the current context RRS feed

  • Question

  • User994779220 posted

    Hello, I made a project the other day and it worked. It worked perfectly as I hoped it would. I saved it and closed and went to bed but the next day, when I opened and started it again, a message showed up saying "There were build errors. Would you like to continue and run the last successful build?". When I clicked "yes", and build opened and worked like it did the other day but then 8 error messages appeared. All errors were Compiler Error CS0103: The name ' ' does not exist in the current context. I searched for solutions but found none that matched my needs or I just couldn't understand it. https://msdn.microsoft.com/en-us/library/t8zbaa6f.aspx gave me a general solution but I don't understand it. Here is my solution and below are the errors. Also, I can't edit or add new things. The variables I wrote such as "sRecognize" and others can't be added or recognized. The list that appears under what you type that shows the list of things to use doesn't show up. Please help me! Thank you!

    ______________________________________________________________________________________________________________________

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using System.Windows.Forms;

    using System.Speech.Synthesis;

    using System.Speech.Recognition;

    using System.Threading;

     

    namespace WindowsFormsApplication1

    {

        public partial class Form1 : Form

        {

            public Form1()

            {

                InitializeComponent();

            }

            SpeechSynthesizer sSynth = new SpeechSynthesizer();

            PromptBuilder pBuilder = new PromptBuilder();

            SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();

            private void Form1_Load(object sender, EventArgs e)

            {

     

            }

     

            private void button1_Click(object sender, EventArgs e)

            {

                pBuilder.ClearContent();

                pBuilder.AppendText(textBox1.Text);

                sSynth.Speak(pBuilder);

            }

     

            private void button2_Click(object sender, EventArgs e)

            {

                button2.Enabled = false;

                button3.Enabled = true;

                Choices sList = new Choices();

                sList.Add(new string[] {"hello", "how", "are", "you", "exit", "thank you",  });

                Grammar Gr = new Grammar(new GrammarBuilder(sList));

                         try

                {

                    sRecognize.RequestRecognizerUpdate();

                    sRecognize.LoadGrammar(Gr);

                    sRecognize.SpeechRecognized += SRecognize_SpeechRecognized ;

                    sRecognize.SetInputToDefaultAudioDevice();

                    sRecognize.RecognizeAsync(RecognizeMode.Multiple);

     

                }

     

                catch

                {

                    return;

                }

            }

     

            private void SRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)

            {

                if (e.Result.Text == "exit")

                {

                    Application.Exit();

                }

                else

                {

                    textBox1.Text = textBox1.Text + " " + e.Result.Text.ToString();

                }

               

            }

     

            private void button3_Click(object sender, EventArgs e)

            {

                sRecognize.RecognizeAsyncStop();

                button2.Enabled = true;

                button3.Enabled = false;

            }

        }

    }

    ____________________________________________________________________________________________________________________________

     

    Severity

    Code

    Description

    Project

    File

    Line

    Error

    CS0103

    The name   'InitializeComponent' does not exist in the current context

    WindowsFormsApplication1

    20

    Error

    CS0103

    The name   'textBox1' does not exist in the current context

    WindowsFormsApplication1

    33

    Error

    CS0103

    The name   'button2' does not exist in the current context

    WindowsFormsApplication1

    39

    Error

    CS0103

    The name   'button3' does not exist in the current context

    WindowsFormsApplication1

    40

    Error

    CS0103

    The name   'textBox1' does not exist in the current context

    WindowsFormsApplication1

    68

    Error

    CS0103

    The name   'textBox1' does not exist in the current context

    WindowsFormsApplication1

    68

    Error

    CS0103

    The name   'button2' does not exist in the current context

    WindowsFormsApplication1

    76

    Error

    CS0103

    The name   'button3' does not exist in the current context

    WindowsFormsApplication1

    77

    Friday, May 29, 2015 5:33 PM

Answers

  • User-166373564 posted

    Hi SamPark,

    Welcome to asp.net forum.

    'textBox1' does not exist in the current context  WindowsFormsApplication1

    Our asp.net forums deal with web-based issues, according to the code snippets show, this is Windows Form issue, you can get help from Windows Form forum, many experts can help you in Windows Form forum.

    With regards,

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 3, 2015 9:48 AM