我借助了一些网络资源创建了以下程序来制作Jarvis:
namespace JarvisFile1{ public partial class Form1 : Form { private void Form1_Load(object sender, EventArgs e) { _recognizer.SetInputToDefaultAudioDevice(); _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"C:\Users\Nelson\Documents\JarvisCommands\greetings.txt"))))); _recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized); _recognizer.RecognizeAsync(RecognizeMode.Multiple); } SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine(); SpeechSynthesizer JARVIS = new SpeechSynthesizer(); string QEvent; string ProcWindow; double timer = 10; int count = 1; Random rnd = new Random(); public Form1() { InitializeComponent(); } void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { int ranNum = rnd.Next(1, 10); string speech = e.Result.Text; switch (speech) { //GREETINGS case "hello": case "hello jarvis": if (ranNum < 6) { JARVIS.Speak("Hello sir"); } else if (ranNum > 5) { JARVIS.Speak("Hi"); } break; case "goodbye": case "goodbye jarvis": case "close": case "close jarvis": JARVIS.Speak("Until next time"); Close(); break; case "jarvis": if (ranNum < 5) { QEvent = ""; JARVIS.Speak("Yes sir"); } else if (ranNum > 4) { QEvent = ""; JARVIS.Speak("Yes?"); } break; } } }}
编译器开始时完美地编译了它,然后给出了以下错误消息:
管理调试助手 ‘RaceOnRCWCleanup’ 在 ‘C:\Users\Nelson\Documents\Visual Studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.vshost.exe’ 中检测到问题。
附加信息: 尝试释放正在使用的RCW。RCW正在当前线程或其他线程上使用。尝试释放正在使用的RCW可能会导致损坏或数据丢失。
作为编程初学者,我不太确定这意味着什么。任何帮助解决这个问题都将不胜感激。如果需要,我可以提供进一步的调试日志。我使用的是Windows 8和Visual Studio 2013。
日志如下:
‘JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll’。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘c:\users\nelson\documents\visual studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.vshost.exe’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll’。无法找到或打开PDB文件。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Speech\v4.0_4.0.0.0__31bf3856ad364e35\System.Speech.dll’。无法找到或打开PDB文件。线程 0x1cf4 已退出,代码为 259 (0x103)。线程 0x11f8 已退出,代码为 259 (0x103)。线程 0xd6c 已退出,代码为 0 (0x0)。线程 0x23c 已退出,代码为 0 (0x0)。线程 0x610 已退出,代码为 259 (0x103)。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘c:\users\nelson\documents\visual studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.exe’。符号已加载。’JarvisFile1.vshost.exe’ (CLR v4.0.30319: JarvisFile1.vshost.exe): 加载了 ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll’。无法找到或打开PDB文件。JarvisFile1.vshost.exe 信息: 0 : SAPI 不实现音标字母选择。线程 0x2270 已退出,代码为 259 (0x103)。线程 0x1b8 已退出,代码为 259 (0x103)。线程 0x1c2c 已退出,代码为 259 (0x103)。线程 0x1650 已退出,代码为 259 (0x103)。程序 ‘[9444] JarvisFile1.vshost.exe: 程序跟踪’ 已退出,代码为 0 (0x0)。程序 ‘[9444] JarvisFile1.vshost.exe’ 已退出,代码为 0 (0x0)。
回答: