我有以下代码:
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”。
这是堆栈跟踪:
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 token) 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 位。
有没有人看到可能出了什么问题?
谢谢你。