GHIElectronics.Extender InvalidOperationException ReservePin

Dear Gadgeteer guys,

I have an exception due to AnalogInput.ReadVoltage() Methode.
Please, help me, thanks in advance.

Here is my code :


 private void SetupAnalogIn(Extender extender)
        {
            if (m_pinSocket < 3 || m_pinSocket > 5)
                throw new Exception("Out of range Analog Input");

            Thread.Sleep(1000);
            switch (m_pinSocket)
            {
                case (int)GT.Socket.Pin.Three:                    
                    m_AnalogInput = extender.SetupAnalogInput(GT.Socket.Pin.Three);
                    break;
                case (int)GT.Socket.Pin.Four:
                    m_AnalogInput = extender.SetupAnalogInput(GT.Socket.Pin.Four);
                    break;
                case (int)GT.Socket.Pin.Five:
                    m_AnalogInput = extender.SetupAnalogInput(GT.Socket.Pin.Five);
                    break;
                default:
                    break;
            }            
        }

Although i make a catch of exception but it still throws :((


public double GetSensorValue()
        {           
            Thread.Sleep(200);
            double _value;            
            //convert the reading to voltage
            try
            {
                double miniVoltage = m_AnalogInput.ReadVoltage() * 1000;
                    
                //calculate Celsius from voltage
                _value = m_Pente * miniVoltage + m_Offset;
                m_AnalogInput.Dispose();
                return _value;             
            }
            catch (InvalidOperationException)
            {
                return -1;   
            }
            catch (Exception)
            {
                return -1;
            }
        }

Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1)

#### Message: 
#### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
#### Microsoft.SPOT.Hardware.AnalogInput::.ctor [IP: 008b] ####
#### Gadgeteer.Interfaces.NativeAnalogInput::set_IsActive [IP: 002e] ####
#### Gadgeteer.Interfaces.NativeAnalogInput::ReadVoltage [IP: 0005] ####
#### TechonovalWebApp.Models.SensorAnalogIn::GetSensorValue [IP: 000f] ####
#### Technosvalg.Tools::GetSignalSensor [IP: 003a] ####
#### Technosvalg.Managers.GloalReactorManager::__AutoPilotActions [IP: 0019] ####
#### Technosvalg.Managers.GloalReactorManager::__RegulationReactorTimer_Tick [IP: 00ef] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0020] ####

What mainboard and socket are you using ? I suspect that this is because you’re using a non A socket, and the exception is thrown back when you setup the pin rather than when you use the pin in getsensorvalue()

@ Brett - I use Spider main board and Extender gadgeteer module (https://www.ghielectronics.com/catalog/product/273)
This Extender module has the SetupAnalogInput method (available at .netmf 4.2) from which I take benefice. This module was connected with Spider card via gate 9 (see in the picture).

Your exception is in reserve pin. Elsewhere in your code are you doing anything with this pin ?