Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

mscorlib.dll error


  • Please log in to reply
5 replies to this topic

#1 zee

zee

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 12 March 2013 - 07:06 AM

Hi,

 

I got an error when deploy piezo. An error message box pop up "An unhandled exception of type 'System.Exception' occurred in mscorlib.dll".. Can anyone please help me where is the problem?



#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 12 March 2013 - 08:44 AM

Hi Zee,

 

Could you please post some code? Right now, that error could mean anything ;)


"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 zee

zee

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 12 March 2013 - 08:58 AM

Hi Stefan,

 

Here's the code below:

 

 

 

public static void Main()
{
// write your code here
 
// store the notes on the music scale and their associated pulse lengths
System.Collections.Hashtable scale = new System.Collections.Hashtable();
 
// low octave
scale.Add("c", 1915u);
scale.Add("d", 1700u);
scale.Add("e", 1519u);
scale.Add("f", 1432u);
scale.Add("g", 1275u);
scale.Add("a", 1136u);
scale.Add("b", 1014u);
 
// high octave
scale.Add("C", 956u);
scale.Add("D", 851u);
scale.Add("E", 758u);
 
// silence ("hold note")
scale.Add("h", 0u);
 
int beatsPerMinute = 90;
int beatTimeInMilliseconds =
60000 / beatsPerMinute; // 60,000 milliseconds per minute
int pauseTimeInMilliseconds = (int)(beatTimeInMilliseconds * 0.1);
 
// define the song (letter of note followed by length of note)
string song = "C1C1C1g1a1a1g2E1E1D1D1C2";
 
// define the speaker
PWM speaker = new PWM(Pins.GPIO_PIN_D5);
 
// interpret and play the song
for (int i = 0; i < song.Length; i += 2)
{
// extract each note and its length in beats
string note = song.Substring(i, 1);
int beatCount = int.Parse(song.Substring(i + 1, 1));
 
// look up the note duration (in microseconds)
uint noteDuration = (uint)scale[note];
 
// play the note for the desired number of beats
speaker.SetPulse(noteDuration * 2, noteDuration);
Thread.Sleep(
beatTimeInMilliseconds * beatCount - pauseTimeInMilliseconds);
 
// pause for 1/10th of a beat in between every note.
speaker.SetDutyCycle(0);
Thread.Sleep(pauseTimeInMilliseconds);
 
}
 
Thread.Sleep(Timeout.Infinite);
}
 
 
 
Thanks for your help! :)


#4 zee

zee

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 12 March 2013 - 09:07 AM

Sorry.. the PWM i editted it to SecretLabs.NETMF.Hardware.PWM speaker = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5);



#5 zee

zee

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 12 March 2013 - 09:17 AM

Sorry Stefan.. My typo error.. Instead of 'i', I accidentally typed '1'..

 

instead of :

 

string note = song.Substring(i, 1);
int beatCount = int.Parse(song.Substring(i + 1, 1));
 
 My silly mistakes:
string note = song.Substring(1, 1);
int beatCount = int.Parse(song.Substring(1 + 1, 1));

 

Sorry for the Inconveniences cause..



#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 March 2013 - 04:46 AM

Hi zee, Which line of code is causing the exception? Try setting a breakpoint on the first line of your code and then press F8 to run one line of code. When that's done, press F8 again. Repeat until you get the exception. Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.