473,382 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

SystemSounds class doesn't work?

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();
Nov 21 '05 #1
5 2718
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 Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Salerno" <jo******@NOSPAMgmail.com> wrote in message
news:0K********************@rcn.net...
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();

Nov 21 '05 #2
Nicholas Paldino [.NET/C# MVP] wrote:
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.
Nov 21 '05 #3
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
"John Salerno" wrote:
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();

Nov 21 '05 #4
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

"mikeq" <mi***@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
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
"John Salerno" wrote:
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();

Nov 21 '05 #5
Thanks a lot Steve I'll try it when I get Visual Studio 2005 in a week or two.
--
-- Mikeq
"Steve Barnett" wrote:
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

"mikeq" <mi***@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
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
"John Salerno" wrote:
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();


Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Drew McCormack | last post by:
I have a C++ template class which contains a static variable whose construction registers the class with a map. Something like this: template <typename T> class M { static Registrar<M>...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
7
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
1
by: sean.chapman | last post by:
I've got a portion of this program that has a timer setup. On the interval I am checking to see if some stuff is changed then want to play the exclamation sound until it has been noticed and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.