views:

427

answers:

6

I have a C# console application that logs a lot to the console (using Trace). Some of the stuff it logs is the compressed representation of a network message (so a lot of that is rendered as funky non-alphabetic characters).

I'm getting system beeps every so often while the application is running. Is it possible that some "text" I am writing to the console is causing them?

(By system beep, I mean from the low-tech speaker inside the PC case, not any kind of Windows sound scheme WAV)


If so, is there any way to disable it for my application? I want to be able to output any possible text without the it being interpreted as a sound request.

+18  A: 

That's usually caused by outputting character code 7, CTRL-G, which is the BEL (bell) character.

The first thing I normally do when buying a new computer or motherboard is to ensure the wire from the motherboard to the speaker is not connected. I haven't used the speaker since the days of Commander Keen (and removing that wire is the best OS-agnostic way of stopping the sound :-).

paxdiablo
I wouldnt do that. The speaker is your first tool to diagnose hardware problems. when the computer just wont turn on
Midhat
And on that one day in a million, I'll reconnect the wire (or more likely just upgrade to the latest and greatest :-).
paxdiablo
It might be impractical to gouge the hardware of all users :-)
frou
+4  A: 

absolutely, if you output ASCII control code "Bell" (0x7) to a console, it beeps.

Ben Schwehn
+1  A: 

\b in output string will cause beep, if not disabled on the OS level.

Dev er dev
+1  A: 

If you don't want if to beep, you'll either have to replace the 0x7 character before outputting it, or disable the "Beep" device driver, which you'll find in the Non-Plug and Play Drivers section, visible if you turn on the Show Hidden Devices option. Or take the speaker out.

SqlACID
A: 

Thank you all for the confirmations - how can I avoid this without inspecting everything before it's logged?

frou
+3  A: 
HKEY_CURRENT_USER\Control Panel\Sound

set the "Beep" key to "no".

Jorge