Answered SystemSounds error

WB1975

Well-known member
Joined
Apr 3, 2020
Messages
87
Programming Experience
Beginner
this line
SystemSounds.Beep.Play(); - SystemSounds gives an error

tried adding

using System.Media; but didnt help

what do i need to do?
 
In documentation you can see which assembly and namespace the type is defined in.
  1. You have to add reference to the assembly if not added already.
  2. The namespace can be imported (using) or you can fully qualify the type in code.

Note that SystemSounds is defined in different assemblies depending on the platform (select in Version dropdown).
 
I have split these posts out to new thread, since this topic is not related to the original thread.
 
You should rethink this. Why not roll your own sounds?

What if the user has system sounds muted, as I do because they are disgusting and annoying. You could add options to your app to allow system sounds to be on or off. If On, play your own sounds.... as for your error... I don't know what to tell you. If you add the using directive for system.media and you still have a red squiggle. Go to build => Build solution.

Alternatively try :

Screenshot_147.jpg


If that doesn't work, you have a messed up system.

Show us the code you have that is meant to play the sound.
 
This thread was split off from another thread where I was showing a way to get the user to answer with just Y or N and return true or false. In my sample code, when the user presses an invalid key, I play the beep sound to give the user some feedback that their keypress was registered, but unfortunately unacceptable.
 
I'm not really going to worry about the beep for now, it wasnt in my requirements and im sure i will come across it in my later travels, who knows.

right now i have int32, Double, Yes and No, should be ok for what i need now.

will add for string

thanks for the help all, really appreciate it!!!
 
Back
Top Bottom