2013-04-17 99 views
0

当使用system.speech.synthesis这样的:访问冲突异常

using (_speech) 
{ 
    _speech.SelectVoice("Anne"); 
    _speech.SpeakCompleted += OnSpeakCompleted; 
    _speech.Rate = Convert.ToInt32(Rate); 
    _speech.Volume = Convert.ToInt32(Volume); 
    _speech.SpeakAsync(text); 
} 

我得到这个错误:

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。改变费率,数量等

有没有人有这种问题的解决方案?解?提示?有什么可以帮助解决这个恼人的问题?

+0

嗨,你解决了这个问题吗? – Yuki

回答

0

只是一个猜测,你打电话给_speech.SpeakAsync(文本);这意味着您正在使用语音异步,在下一行中通过关闭使用来处理_speech对象。我可以想象这会导致问题。处理结果后,应该抛弃_speech对象。

+0

我刚刚尝试删除使用,但它给了我同样的错误 –