FEZ Hydra - Analog Input - Digital Output Problems

Hi,
i need 2 DigitalOutputs to control a multiplexer, the AnalogInput reads the values.
The Hydra throws exceptions on all ports ?

Socket socket = Socket.GetSocket(9, true, null, null);
DigitalOutput mOutputPortA = new DigitalOutput(socket, Socket.Pin.Four, false, null);
DigitalOutput  mOutputPortB = new DigitalOutput(socket, Socket.Pin.Five, false, null);

Exception Gadgeteer.Socket+InvalidSocketException - 0x00000000 (2)

#### Message: Invalid socket number 9 specified.
#### Gadgeteer.Socket::GetSocket [IP: 00a2] ####
#### HomeControlApp.Temperature::Init [IP: 000a] ####
#### HomeControlApp.Temperature::.ctor [IP: 000a] ####
#### HomeControlApp.Temperature::.cctor [IP: 0003] ####
Socket analog = Socket.GetSocket(14, true, null, null);
AnalogInput mAnalogPort = new AnalogInput(analog, Socket.Pin.Five, null);

Exception Gadgeteer.Socket+InvalidSocketException - 0x00000000 (2)

#### Message: Invalid socket number 14 specified.
#### Gadgeteer.Socket::GetSocket [IP: 00a2] ####
#### HomeControlApp.Temperature::Init [IP: 0061] ####
#### HomeControlApp.Temperature::.ctor [IP: 000a] ####
#### HomeControlApp.Temperature::.cctor [IP: 0003] ####

Best regards

Andreas

I found the problem:

The FEZ Hydra initialize the Sockets in the FEZHydra() ctor.
My Digital and Analog Ports are initialized in following Singelton:

public sealed class Singleton
{
   private static readonly Singleton instance = new Singleton();
   
   private Singleton(){}

   public static Singleton Instance
   {
      get 
      {
         return instance; 
      }
   }
}

The Singelton object was created bevor the FEZHydra ctor() is called.

Now i use this Singleton :

public class Singleton
{
   private static Singleton instance;

   private Singleton() {}

   public static Singleton Instance
   {
      get 
      {
         if (instance == null)
         {
            instance = new Singleton();
         }
         return instance;
      }
   }
}

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)