语音程序适用于vs2008,但不适用于2010 [英] voice program works on vs2008 but not in 2010

查看:69
本文介绍了语音程序适用于vs2008,但不适用于2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在Visual Studio 2008中正常运行的程序,但是
在2010 Visual Studio(在另一台计算机上)运行它时出现运行时错误
错误是对象引用未设置为对象的实例."
我添加了Microsoft speach libiraray和system.speach
这是程序的一部分

i have a program which works fine in visual studio 2008 but
i have got a run time error when i run it in 2010 visual studio (in another computer)
The error is "Object reference not set to an instance of an object."
i added the microsoft speach libiraray and system.speach
this is part of the program

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 SpeechLib;
using System.Speech.Synthesis;
using System.Speech.Recognition;
using System.Media;
using System.Globalization;
//using Microsoft.Speech.Recognition;
//using Microsoft.Speech.Synthesis;
.
.
.
    public partial class Form1 : Form
    {   SpVoice voice = null;
        public Form1()
        {
            InitializeComponent();
        }
        private void FormLoad(object sender, EventArgs e)
        {
            voice = new SpVoice();
        }
        private void HellowClick(object sender, EventArgs e)
        {
            voice.Speak("Hello World!", SpeechVoiceSpeakFlags.SVSFDefault);//<---- here is the error

推荐答案

Form_Load或Form_Shown中的错误可能被误吞了(我不记得在其上找到更多信息的网站). /> 因此,我认为voice = new SpVoice();失败了.您可以在其周围添加一个try-catch(在这种情况下,由于catch子句在同一函数中,因此它将被catch子句捕获),从而获得有关失败原因的更多信息.
可能有32位与64位问题.
Errors in Form_Load or also Form_Shown may happen to be swallowed (I do not remember the web site where I found more information on it).
Hence I think that voice = new SpVoice(); failed. You can add a try-catch around it (in this case, the error will be caught by the catch clause because it is in the same function) and thus get more information about the reason of the failure.
There could be e.g. a 32bit vs. 64bit issue.


这篇关于语音程序适用于vs2008,但不适用于2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆