University project error message

Hi guys! my university project is an electronic stethoscope, using a FEZ cerbuino bee and a mic inserted into the end of a normal stethoscope. The objective is to obtain a value for BPM in visual studio. When running the program shown below, I seem to randomly get this error message;

“An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll”

Could someone give my guidance as to why this happens?

using System;
using Microsoft.SPOT;
using System.Threading;
using Microsoft.SPOT.Hardware;
using GHI.Premium.Hardware;
using GHI.OSHW.Hardware;

namespace MFConsoleApplication1
    public class Program
        public static void Main()
            AnalogInput lightSensor = new AnalogInput(FEZCerbuino.Pin.AnalogIn.A1);

            double lightSensorReading = 0;
            while (true)
                lightSensorReading = lightSensor.Read();
            void programStarted()
                Debug.Print("Program Started");


output from debug;

A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll

The program '[22] Micro Framework application: Managed' has exited with code 0 (0x0).

Try using ReadRaw and see if you still get that exception.

@ ks09aao - dunno if it will make a difference but remove any references to GHI.Premium.Hardware;

1 Like

@ Justin - Good catch!

removing the reference did the trick! many thanks, I’ve spent an awfully long time trying to solve that!

Sweet :slight_smile:

Could we know the reason af such a solution?

GHI.Premium.Hardware is not on OSHW board.

I would have expected that the code simply didn’t launch instead of working with exception occuring…