Method works on Emulator but no on Microsoft Surface unit?

144 views Asked by At

I have the following code. The StartRecord method trows an error on the Microsoft Surface Unit. But when I'm testing it on the emulator, it all works great. Any hints how

1) to find the exception that is thrown on the Microsoft Surface Unit?

2) to find the error in the code? any assumptions?

        private void StartRecord(object sender, ContactEventArgs e)
        {
            isRecording = true;
            StartButton.IsEnabled = false;
            recordTimer = new Timer(10);
            recordTimer.Elapsed += new ElapsedEventHandler(recordTimer_Elapsed);
            PlaybackRoot.Visibility = System.Windows.Visibility.Collapsed;
            EllapsedRecord.Visibility = System.Windows.Visibility.Visible;
            InputLevel.Visibility = System.Windows.Visibility.Visible;
            long time = DateTime.Now.Ticks;
            String fileName = Convert.ToString(time) + ".wav";
            Console.WriteLine(fileName);
            startTime = DateTime.UtcNow;
            recordTimer.Start();
            record = new AudioRecording(fileName);
            record.getSampleAggregator().MaximumCalculated += new EventHandler<MaxSampleEventArgs>(AudioControl_MaximumCalculated);
            record.start();
        }
2

There are 2 answers

0
brunnerh On BEST ANSWER

I am not familiar with Surface but if you don't have any debugging tools i would start by wrapping everything in a try block, so the exception message and callstack can be retrieved:

try
{
    //Method code here
}
catch (Exception ex)
{
    //Output the exeption messages here, use a recursive method to get those of inner exceptions as well.
    //Example method to get the messages as string:
    //
    //public static string ExceptionToString(Exception ex)
    //{
    //  if (ex == null) return "";
    //  else return " [" + ex.Message + ExceptionToString(ex.InnerException) + "]";
    //}
    //
    //Also get the StackTrace (ex.StackTrace) and print it using whatever means available.
}

This should allow you to further narrow the problem down to a specific operation.

1
Robert Levy On

Put the Surface into "admin mode" and run your app from there. Also, make sure you are using the debug build of your app and not release.