在页面加载中引用语音合成但仍然获得NullReferenceException

时间:2013-12-08 10:13:12

标签: c# asp.net nullreferenceexception speech-synthesis

问题在于,当我单击按钮时,它会读取文本,但即使在完成后,页面仍在等待localhost,所以我想也许我应该在页面加载时实例化读取器,就像我在下面的代码,获得NullReferenceException

protected void Page_Load(object sender, EventArgs e)
{
        if (!IsPostBack)
        {
            Label1.Text = "click button";
            reader = new SpeechSynthesizer();
        }
        else
        {}
}

protected void Button1_Click(object sender, EventArgs e)
{
          reader.SpeakAsync(TextBox1.Text);//getting the error here
            Label1.Text = "SPEAKING";
}

0 个答案:

没有答案