"Managed Debugging Assistant 'RaceOnRCWCleanup' has detected a problem in "贾维斯
"Managed Debugging Assistant 'RaceOnRCWCleanup' has detected a problem in " Jarvis
我借助一些互联网资源创建了以下程序来创建 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;
}
}
}
}
编译器先是完美编译,然后报错如下:
"Managed Debugging Assistant 'RaceOnRCWCleanup' has detected a problem
in 'C:\Users\Nelson\Documents\Visual Studio
2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.vshost.exe'.
Additional information: An attempt has been made to free an RCW that
is in use. The RCW is in use on the active thread or another thread.
Attempting to free an in-use RCW can cause corruption or data loss."
我不太清楚这意味着什么,因为我是编码初学者。
解决此问题的任何帮助将不胜感激。如果需要,我可以提供进一步的调试日志。我正在使用 windows 8 和 visual studio 2013.
日志如下:
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'c:\users\nelson\documents\visual studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.vshost.exe'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Speech\v4.0_4.0.0.0__31bf3856ad364e35\System.Speech.dll'. Cannot find or open the PDB file.
The thread 0x1cf4 has exited with code 259 (0x103).
The thread 0x11f8 has exited with code 259 (0x103).
The thread 0xd6c has exited with code 0 (0x0).
The thread 0x23c has exited with code 0 (0x0).
The thread 0x610 has exited with code 259 (0x103).
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'c:\users\nelson\documents\visual studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.exe'. Symbols loaded.
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Cannot find or open the PDB file.
JarvisFile1.vshost.exe Information: 0 : SAPI does not implement phonetic alphabet selection.
The thread 0x2270 has exited with code 259 (0x103).
The thread 0x1b8 has exited with code 259 (0x103).
The thread 0x1c2c has exited with code 259 (0x103).
The thread 0x1650 has exited with code 259 (0x103).
The program '[9444] JarvisFile1.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[9444] JarvisFile1.vshost.exe' has exited with code 0 (0x0).
您似乎需要释放或等到语音引擎资源释放后再关闭表单。该语音引擎可能有一个释放资源的明确调用。只是一个猜测,但值得研究。
编辑:
取自 MSDN 网站
Always call Dispose before you release your last reference to the speech recognizer. Otherwise, the resources it is using will not be freed until the garbage collector calls the recognizer object's Finalize method.
您可以连接到 RecognizeCompleted 事件,当您完成 'stop' 时,在您的引擎上调用 release,然后调用 Close()
所以你需要代码:
.
.
case "close jarvis":
_recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(_recognizer_RecognizeCompleted);
JARVIS.Speak("Until next time");
break;
.
.
void _recognizer_RecognizeCompleted(RecognizeCompletedEventArgs e)
{
_recognizer.Release();
Close();
]
由于您是编码新手,所以我想首先展示这种方式,因为您熟悉语法。但对你的情况更好的方法是:
case "close jarvis":
_recognizer.RecognizeCompleted += (e) => { Close(); }
JARVIS.Speak("Until next time");
break;
这是内联事件处理程序而不是使用委托。
我借助一些互联网资源创建了以下程序来创建 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;
}
}
}
}
编译器先是完美编译,然后报错如下:
"Managed Debugging Assistant 'RaceOnRCWCleanup' has detected a problem in 'C:\Users\Nelson\Documents\Visual Studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.vshost.exe'.
Additional information: An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss."
我不太清楚这意味着什么,因为我是编码初学者。 解决此问题的任何帮助将不胜感激。如果需要,我可以提供进一步的调试日志。我正在使用 windows 8 和 visual studio 2013.
日志如下:
'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'c:\users\nelson\documents\visual studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.vshost.exe'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Speech\v4.0_4.0.0.0__31bf3856ad364e35\System.Speech.dll'. Cannot find or open the PDB file. The thread 0x1cf4 has exited with code 259 (0x103). The thread 0x11f8 has exited with code 259 (0x103). The thread 0xd6c has exited with code 0 (0x0). The thread 0x23c has exited with code 0 (0x0). The thread 0x610 has exited with code 259 (0x103). 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'c:\users\nelson\documents\visual studio 2013\Projects\JarvisFile1\JarvisFile1\bin\Debug\JarvisFile1.exe'. Symbols loaded. 'JarvisFile1.vshost.exe' (CLR v4.0.30319: JarvisFile1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Cannot find or open the PDB file. JarvisFile1.vshost.exe Information: 0 : SAPI does not implement phonetic alphabet selection. The thread 0x2270 has exited with code 259 (0x103). The thread 0x1b8 has exited with code 259 (0x103). The thread 0x1c2c has exited with code 259 (0x103). The thread 0x1650 has exited with code 259 (0x103). The program '[9444] JarvisFile1.vshost.exe: Program Trace' has exited with code 0 (0x0). The program '[9444] JarvisFile1.vshost.exe' has exited with code 0 (0x0).
您似乎需要释放或等到语音引擎资源释放后再关闭表单。该语音引擎可能有一个释放资源的明确调用。只是一个猜测,但值得研究。
编辑:
取自 MSDN 网站
Always call Dispose before you release your last reference to the speech recognizer. Otherwise, the resources it is using will not be freed until the garbage collector calls the recognizer object's Finalize method.
您可以连接到 RecognizeCompleted 事件,当您完成 'stop' 时,在您的引擎上调用 release,然后调用 Close()
所以你需要代码:
.
.
case "close jarvis":
_recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(_recognizer_RecognizeCompleted);
JARVIS.Speak("Until next time");
break;
.
.
void _recognizer_RecognizeCompleted(RecognizeCompletedEventArgs e)
{
_recognizer.Release();
Close();
]
由于您是编码新手,所以我想首先展示这种方式,因为您熟悉语法。但对你的情况更好的方法是:
case "close jarvis":
_recognizer.RecognizeCompleted += (e) => { Close(); }
JARVIS.Speak("Until next time");
break;
这是内联事件处理程序而不是使用委托。