问题在于,当我单击按钮时,它会读取文本,但即使在完成后,页面仍在等待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";
}