SystemSounds class doesn't work?

  • Thread starter Thread starter John Salerno
  • Start date Start date
J

John Salerno

I just tried out the SystemSounds class, following along with C#
Developer's Notebook, but it doesn't seem to work. I just put the
following line on a button's click event, but when run the app and click
the button, there's no sound at all.

SystemSounds.Asterisk.Play();
 
John,

It is most likely that an exception is being thrown and the code that is
firing the events is swallowing the exception.

Wrap the line in a try/catch block, and find out what the exception is.

Hope this helps.
 
Nicholas said:
John,

It is most likely that an exception is being thrown and the code that is
firing the events is swallowing the exception.

Wrap the line in a try/catch block, and find out what the exception is.

Hope this helps.

No luck there. It might just be my system. I've noticed that lately my
startup and shutdown sounds do not play either when my computer boots
and shuts down. This just happened one day for no apparent reason. So
maybe this is the same type of thing.
 
Would you mind telling me what the full namespace of the SystemSounds Class
is, I don't see it in my Visual Studio Help. I have Vs .NET 2003. Is this a
VS 2005 new feature?

Thank you
-- Mikeq
 
It's in System.Media and is only available for .Net 2.0.

using System.Media; // Make sure you have this for
SystemSounds

namespace Sounds
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
SystemSounds.Asterisk.Play();
}
}
}

Works for me...

HTH
Steve
 
Back
Top