解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,错误0x80040154,没有注册类有关问题分析和解决方法

解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,异常0x80040154,没有注册类问题分析和解决办法

检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,异常0x80040154,没有注册类问题分析和解决办法

提供源代码,和解决问题的文件下载。

问题分析和解决

        //阅读函数
        private void Read(string text)
        {
            SpVoice sp = new SpVoice();//报错位置
              sp.Rate = GetSpeedSelected();
            SpeechVoiceSpeakFlags sFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
            sp.Speak(text, sFlags);
        }

报错信息:

有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.Runtime.InteropServices.COMException (0x80040154): 检索 COM 类工厂中 

CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,原因是出现以下错误: 

80040154 没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))。
   在 System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject

(RuntimeType objectType)
   在 System.Runtime.Remoting.Activation.ActivationServices.CreateInstance

(RuntimeType serverType)
   在 System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK

(RuntimeType serverType, Object[] props, Boolean bNewObj)
   在 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean 

publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal&

ctor, Boolean& bNeedSecurityCheck)
   在 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean 

skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   在 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean 

skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   在 System.Activator.CreateInstance(Type type, Boolean nonPublic)
   在 System.Activator.CreateInstance(Type type)
   在 SpeakDemo.Form1.Read(String text) 位置 c:\Users\Administrator\Desktop

\SpeakDemo\SpeakDemo\SpeakDemo\Form1.cs:行号 32
   在 SpeakDemo.Form1.btnRead_Click(Object sender, EventArgs e) 位置 c:\Users

\Administrator\Desktop\SpeakDemo\SpeakDemo\SpeakDemo\Form1.cs:行号 43
   在 System.Windows.Forms.Control.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, 

Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
   在 System.Windows.Forms.Button.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

解决办法:

如果方法一不能解决问题,可以尝试方法二。

方法一

检索 COM 类工厂中 CLSID 为 {XXXX-XXXX-XXX-XXXXX-XXX} 的组件时失败,原因是出现以下错误: 80040154。

如以上问题出现,多半是因为COM控件未在目标机器上面注册造成的
解决方法:
Regsvr32 .net中引用控件的名称
如果注册成功,问题不出现

但是如果是在x64位的系统中,即使控件注册成功,错误依照提示,是因为大多数第三方写的COM控件,只支持32位的系统,

在VS中找到引用控件所在的项目--〉属性--〉生成--〉常规---〉目标平台---〉选择X86即可解决。

方法二

原因:有些GHOST版win 系统没有启动语音引擎 控制面板上没有 语音 这个选项

修复:打开“C:\Windows\Inf” 看有没有sapi5.inf 这个文件,如果没有网上下载,sapi5.inf复制到“C:\Windows\Inf”文件夹下。

下载地址:http://download.csdn.net/detail/wyx100/8430545

解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,错误0x80040154,没有注册类有关问题分析和解决方法

 

解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,错误0x80040154,没有注册类有关问题分析和解决方法

右键单击文件“sapi5.inf”,选择“安装”,提示“提示插入系统盘……”,没系统盘的话点“浏览”,从TTS解压的目录中选择需要的系统文件。

TTS下载地址:

http://download.csdn.net/detail/wyx100/8430545    xpTTS.zip

 

安装完成后,C:\Program Files\Common Files\microsoft shared\Speech 文件夹下

解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,错误0x80040154,没有注册类有关问题分析和解决方法

 

安装完成后,可以运行SpeakDemo.exe进行测试,如果不成功,继续操作。

解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,错误0x80040154,没有注册类有关问题分析和解决方法

运行sln(解决方案)前,需要修改sln文件中版本和实际使用的vs一致。如果没有安装vs,直接运行debub下的 SpeakDemo.exe

解决检索 COM 类工厂中 CLSID 为 {96749377-3391-11D2-9EE3-00C04F797396} 的组件失败,错误0x80040154,没有注册类有关问题分析和解决方法

没有安装盘,把下载到的 [微软TTS5.1语音引擎(中文).msi]改名为微软TTS5.1语音引擎(中文).rar 用RAR解压,
改成提示中对应的文件名即可.
C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.cpl
C:\Program Files\Common Files\SpeechEngines\Microsoft\Lexicon\1033\r1033tts.lxa