我正在使用 Visual Studio 2010 创建一个带有 Kinect SDK 1.6 的 XNA 应用程序。我有一个问题,即在调试应用程序后构建通常会失败(并非总是)。有一个进程正在锁定KinectDrobePrototype1.exe
。
Error 12 Unable to copy file "obj\x86\Debug\KinectDrobePrototype1.exe" to
"bin\x86\Debug\KinectDrobePrototype1.exe". The process cannot access the file
'bin\x86\Debug\KinectDrobePrototype1.exe' because it is being used by another
process.
Error 11 Could not copy "obj\x86\Debug\KinectDrobePrototype1.exe" to
"bin\x86\Debug\KinectDrobePrototype1.exe". Exceeded retry count of 10. Failed.
我使用了Process Explorer,它告诉我这是System
进程。
Process | PID | Type | Name
System 4 File C:\Users\ ... \KinectDrobePrototype1\KinectDrobePrototype1\KinectDrobePrototype1\bin\x86\Debug\KinectDrobePrototype1.exe
我看过类似的帖子,但没有帮助。我觉得我的应用程序中一定有一些东西仍然可以处理一些东西。我确定当应用程序终止时,以下代码会在我的KinectManager
类中执行。
public void CleanUp()
{
if (ActiveKinectDevice != null)
UnintialiseDevice(ActiveKinectDevice);
}
private void UnintialiseDevice(KinectSensor device)
{
device.Stop();
device.ColorStream.Disable();
_ColourPixelData = null;
device.DepthStream.Disable();
_DepthPixelData = null;
device.SkeletonStream.Disable();
_SkeletonData = null;
}
我对 XNA 很陌生,所以可能有一些我没有做过的事情。在UnloadContent
我有以下内容:
protected override void UnloadContent()
{
_KinectManager.CleanUp();
_DrawingManager.CleanUp();
}
然后在我的DrawingManager
课堂上,我处理了我使用过的一些纹理,我的SpriteBatch
和GraphicsDevice
:
public void CleanUp()
{
HandIcon.Dispose();
JointIcon.Dispose();
_ColourImage.Dispose();
_DepthImage.Dispose();
_SpriteBatch.Dispose();
_GraphicsDevice.Dispose();
}
有没有人有任何建议?还是我犯了一个明显的错误?
编辑 1:我忘了提到我正在使用 Kinect 的轮询方法,这就是为什么我没有取消注册任何事件的原因。
编辑 2:为澄清起见,系统进程最终会释放文件 - 它不会保持锁定状态。我认为这通常需要一到两分钟。
更新 1:我确实安装了防病毒软件。我已禁用它,但它并没有解决问题。
更新 2:我可以确认这是我的台式机特有的问题。我还没有在我的笔记本电脑上重现这个问题。