title: Play sound with C# using DirectSound (DirectX API)
body: <p>This might seem like a very basic question, but not even by researching for hours I could find out what I did wrong.</p>
  
  <p>I tried to write a simple console application that is supposed to play a sound from a resource, and this is my code:</p>
  
  <pre><code>using System;
  using Microsoft.DirectX.DirectSound;
  
  namespace AudioPlayer
  {
      class Program
      {
          static void Main()
          {
              Console.WriteLine("Playing...");
  
              Device device = new Device();
              SecondaryBuffer buffer = new SecondaryBuffer(AudioPlayer.Properties.Resources.AudioFile, device);
              // AudioPlayer.Properties.Resources.AudioFile returns a stream
  
              buffer.Play(0, BufferPlayFlags.Default);
  
              Console.WriteLine("Finished");
              Console.ReadKey(true);
          }
      }
  }
  </code></pre>
  
  <p>But all I get is a console window with no text although at least "Playing..." should be printed, and there is no sound as well.</p>
  
  <p>I am using Visual Studio 2015 which provides the option to pause an application, and if I do that, it tells me that all threads are currently processing external code. Considering that, I assumed that my program got stuck while creating the device or the buffer, but then again <code>Console.WriteLine("Playing...");</code> seems remaining unexecuted!</p>
  
  <p>Additional inforamtions:</p>
  
  <ul>
  <li><p>.NET framework version 4.6</p></li>
  <li><p>32-bit program</p></li>
  <li><p>sound file format: WAV</p></li>
  <li><p>codec: MPEG-1 Audio Layer 3 (MP3)</p></li>
  </ul>
  
  <p>It would be really great if someone could explain where I failed! And sorry if this is a duplicate or if I made a really <em>really</em> silly mistake, but after all the time spent on this, I still can neither figure out how to solve it, nor find an already existing explanation.</p>