我有以下代码:
Imports System.Speech.Synthesis
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim m_Synth As New SpeechSynthesizer
For Each v As InstalledVoice In m_Synth.GetInstalledVoices
Debug.WriteLine(v.VoiceInfo.Name)
Next
End Sub
End Class
停在
For Each v As InstalledVoice In m_Synth.GetInstalledVoices
并给我错误“System.FormatException”。
这是StackTrace:
bei System.Number.StringToNumber(String str,NumberStyles options,NumberBuffer& number,NumberFormatInfo info,Boolean parseDecimal) bei System.Number.ParseInt32(String s,NumberStyles style,NumberFormatInfo info) bei System.Speech.Internal.SapiAttributeParser.GetCultureInfoFromLanguageString(String valueString) bei System.Speech.Synthesis.VoiceInfo..ctor(VoiceObjectToken令牌) bei System.Speech.Internal.Synthesis.VoiceSynthesis.BuildInstalledVoices(VoiceSynthesis voiceSynthesizer) bei System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speechSynthesizer) bei System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer() bei System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices() bei voice_test.Form1.Form1_Load(Object sender,EventArgs e)在C:\ Users \ MyUser \ Downloads \ kontakt \ voice test \ voice test \ Form1.vb:Zeile 8。
仅当我将项目的“扩展编译选项”设置为“目标CPU:x86”时,才会出现此问题。 如果我将其设置为“目标CPU:任何CPU”,代码运行时没有任何错误,并按预期返回名称。 目标框架是“.NET Framework 4”。 我正在运行Win 7 64位。
有人看到可能出现的问题吗?
谢谢。