Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implicitly convertible to 'System.IDisposable' error

Tags:

c#

kinect

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?

like image 486
CodeKinect Avatar asked Feb 12 '14 05:02

CodeKinect


2 Answers

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.

like image 61
Vishal Avatar answered Sep 21 '22 18:09

Vishal


You can create like that :

public class HelloTest : IDisposable
{
    void IDisposable.Dispose()
    {

    }

    public void GetData()
    {

    }
}

after then you can able create object like

using (HelloTest Ht = new HelloTest())
        {
            Ht.GetData();
        }

I hope above example helpfull

like image 44
VishalDream Avatar answered Sep 18 '22 18:09

VishalDream