I am using Visual Studio 2010 creating a XNA application with the Kinect SDK 1.6. I have a problem that the build usually fails (not always) after debugging the application. There is a process that is locking 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.
I have used Process Explorer which tells me it is the System
process.
Process | PID | Type | Name
System 4 File C:\Users\ ... \KinectDrobePrototype1\KinectDrobePrototype1\KinectDrobePrototype1\bin\x86\Debug\KinectDrobePrototype1.exe
I have seen similar posts like this but it hasn't helped. I feel that there must be something in my application that still has a handle on something. I know for certain that when the application terminates the following code executes within my KinectManager
class.
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;
}
I am very new to XNA so it possible that there is something I have not done. On the UnloadContent
I have the following:
protected override void UnloadContent()
{
_KinectManager.CleanUp();
_DrawingManager.CleanUp();
}
And then in my DrawingManager
class I dispose of the few textures I have used, my SpriteBatch
and GraphicsDevice
:
public void CleanUp()
{
HandIcon.Dispose();
JointIcon.Dispose();
_ColourImage.Dispose();
_DepthImage.Dispose();
_SpriteBatch.Dispose();
_GraphicsDevice.Dispose();
}
Has anyone got any suggestions? Or is there an obvious mistake that I have made?
Edit 1: I forgot to mention that I am using the polling method for the Kinect, which is why I have not unregistered for any events.
Edit 2: For clarification, the System process does release the file eventually - it does not stay locked. I think this usually takes between one to two minutes.
Update 1: I do have antivirus software installed. I have disabled it but it has not solved the issue.
Update 2: I can confirm this is a problem specific to my desktop machine. I am yet to reproduce the problem on my laptop.