Implicitly convertible to 'System.IDisposable' error

CodeKinect picture CodeKinect · Feb 12, 2014 · Viewed 76.6k times · Source

This is what I'm trying to do:

private KinectAudioSource CreateAudioSource()
{
    var source = KinectSensor.KinectSensors[0].AudioSource;
    source.NoiseSuppression = _isNoiseSuppressionOn;
    source.AutomaticGainControlEnabled = _isAutomaticGainOn;
    return source;
}
private object lockObj = new object();
private void RecordKinectAudio()
{
    lock (lockObj)
    {
        using (var source = CreateAudioSource())
        {
        }
    }
}

The 'using' statement gives one error which states:

'Microsoft.Kinect.KinectAudioSource':type used in a using statement must be implicitly convertible to 'System.IDisposable'

How do I eliminate this error and what does it mean?

Answer

Vishal picture Vishal · Jun 29, 2016

I am very late to the party, but I should say:

You must add a reference to Entity Framework if you get this error while using context inside using statement.