2

I'm new to programming and I'm trying to use the the class SoundPlayer in a C# project on Visual Studio for Mac where I want to play a sine wave but this message occurred when I typed in "SoundPlayer":

The type name 'SoundPlayer' could not be found in the namespace 'System.Media'. This type has been forwarded to assembly 'System.Windows.Extensions, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly.

Any suggestions?

  • Did you think that maybe `Consider adding a reference to that assembly` already counts as a suggestion? Did you try it? – ADyson May 19 '21 at 13:56
  • The documentation can be handy. Take a look at the docs for System.Media.SoundPlayer: https://learn.microsoft.com/en-us/dotnet/api/system.media.soundplayer. Right up at the top: _Assembly: System.Windows.Extensions.dll_. It matches up with _Consider adding a reference..._ – Flydog57 May 19 '21 at 14:00
  • Thanks @Flydog57 for your kind reply. I have read the docs but I still cannot understand how it works. Probably my knowledges of Visual Studio and C# are still to weak. Thanks anyway – Umberto Boldarin May 19 '21 at 14:50
  • Right-click the project in the Solution Explorer. Choose _Add_ then _Reference_. In the dialog box that pops up, click on "Assemblies". Find _System.Windows.Extensions_. Click on it. A check box appears next to it. Click the check box, click OK – Flydog57 May 19 '21 at 15:17
  • SoundPlayer is only available on Windows. That's why it's called "System.WINDOWS.Extensions" :-) You could try NAudio but it is quite big for simple tasks. – AudioGuy Aug 19 '23 at 05:54

0 Answers0