2011-07-02 49 views
0

我在.NET Framework 3.5中使用此代碼,用於在Visual 7中使用visual studio 2010 professional創建語法,但我收到類似於 的錯誤類型或名稱空間名稱「講話」在系統中不存在(是否缺少using指令或程序集引用。獲取錯誤就像你在我的程序中缺少程序集引用

類型或命名空間名稱「SpeechRecognitionType」找不到(是否缺少using指令或程序集引用,

與其他類似linq不存在的其他類似,您是缺少裝配參考物件

`using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;使用System.Linq的 ; using System.Text;使用System.Windows.Forms的 ; using System.Speech.Recognition;使用System.Threading的 ;

命名空間SpeechRecogTest { 公共部分Form1類:形式 { SpeechRecognitionEngine SR =新SpeechRecognitionEngine();

public Form1() 
    { 
     InitializeComponent(); 
    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 
     //Create grammar 
     Choices words = new Choices(); 
     words.Add("Hi"); 
     words.Add("No"); 
     words.Add("Yes"); 

     Grammar wordsList = new Grammar(new GrammarBuilder(words)); 

     wordsList.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized); 
     sr.LoadGrammar(wordsList); 

    } 

    void rec_SpeechRecognized(object sender, RecognitionEventArgs e) 
    { 
     MessageBox.Show(e.Result.Text); 
    } 
} 

}`

回答

0

當它詢問 「是否缺少using指令或程序集引用」?您不會錯過使用指令,因此您很可能錯過了組件。右鍵點擊「References」=>「Add Reference」=> NET tab => System.Speech dll。