首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >system.speech.synthesis中的访问冲突异常

system.speech.synthesis中的访问冲突异常
EN

Stack Overflow用户
提问于 2013-04-17 17:56:58
回答 1查看 422关注 0票数 0
代码语言:javascript
复制
using (_speech)
{
    _speech.SelectVoice("Anne");
    _speech.SpeakCompleted += OnSpeakCompleted;
    _speech.Rate = Convert.ToInt32(Rate);
    _speech.Volume = Convert.ToInt32(Volume);
    _speech.SpeakAsync(text);
}

我得到了这个错误:

代码语言:javascript
复制
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Speech
StackTrace:
       at System.Speech.Internal.ObjectTokens.ObjectToken.ISpObjectWithToken.SetObjectToken(ISpObjectToken pToken)
       at System.Speech.Internal.ObjectTokens.ObjectToken.CreateObjectFromToken[T](String name)
       at System.Speech.Internal.Synthesis.VoiceSynthesis.GetComEngine(VoiceInfo voiceInfo)
       at System.Speech.Internal.Synthesis.VoiceSynthesis.GetProxyEngine(VoiceInfo voiceInfo)
       at System.Speech.Internal.Synthesis.VoiceSynthesis.ThreadProc()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
InnerException: 

该错误在创建语音合成器的对象时不会发生,但在使用时会发生错误。Fx。

有谁有解决这类问题的办法吗?解决方案?提示?有什么可以帮助解决这个烦人的问题的吗?

EN

回答 1

Stack Overflow用户

发布于 2013-04-17 18:03:01

仅供猜测,您正在调用_speech.SpeakAsync(text);这意味着您正在使用语音异步,在下一行中,您将通过关闭using来释放_speech对象。我可以想象,这可能会导致问题。在得到处理结果后,您应该释放_speech对象。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16057044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档