问题描述
从IClassFactory为CLSID为{47206204-5ECA-11D2-960F-00C04F8EE628}的COM组件创建实例失败,原因是出现以下错误:80045078异常来自HRESULT:0x80045078。代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSpeechLib;usingSystem.Windows.Controls;usingSystem.Windows;namespaceSpeech{publicclassSpRecognition{privatestaticSpRecognition_Instance=null;privateSpeechLib.ISpeechRecoGrammarisrg;privateSpeechLib.SpSharedRecoContextClassssrContex=null;publicdelegatevoidStringEvent(stringstr);publicStringEventSetMessage;privateSpRecognition(){ssrContex=newSpSharedRecoContextClass();isrg=ssrContex.CreateGrammar(1);SpeechLib._ISpeechRecoContextEvents_RecognitionEventHandlerrecHandle=new_ISpeechRecoContextEvents_RecognitionEventHandler(ContexRecognition);ssrContex.Recognition+=recHandle;}publicvoidBeginRec(){isrg.DictationSetState(SpeechRuleState.SGDSActive);}publicstaticSpRecognitioninstance(){try{if(_Instance==null)_Instance=newSpRecognition();}catch(Exceptionex){MessageBox.Show(ex.ToString());}return_Instance;}publicvoidCloseRec(){isrg.DictationSetState(SpeechRuleState.SGDSInactive);}publicvoidContexRecognition(intiIndex,objectobj,SpeechLib.SpeechRecognitionTypetype,SpeechLib.ISpeechRecoResultresult){if(SetMessage!=null){SetMessage(result.PhraseInfo.GetText(0,-1,true));}}}}C#调用WPF的界面调用失败问题出现在以下代码段:publicstaticSpRecognitioninstance(){try{if(_Instance==null)_Instance=newSpRecognition();}catch(Exceptionex){MessageBox.Show(ex.ToString());}return_Instance;}操作系统为win864位开发环境为VS2010引用Interop.SpeechLib.dll为5.4版本小弟比较菜菜坐等诸位仁兄相助多谢!
解决方案
解决方案二:
先自己小顶一下本来看这个“从IClassFactory为CLSID为{47206204-5ECA-11D2-960F-00C04F8EE628}的COM组件创建实例失败,原因是出现以下错误:80045078异常来自HRESULT:0x80045078。”错误,最先认为是没有注册dll但是注册时候也报错真真一路堵心啊不晓得咋办了55555求救ing
解决方案三:
Interop.SpeechLib.dll只是对COM的调用封装。不是实际API接口。你确保自己机器上装了MicrosoftTextSpeechSDK相应版本了没?
解决方案四:
从Win7开始,语音识别和语音合成,就可以直接在C#·中添加system.speech引用,这个是。Net支持的dll,不需要添加COM版本的