Im using Microsoft Visual C# 2010 Express

Basically I am making a simple slot machine game. The application currently works perfectly using the debugger however the sounds do not work properly after publishing.

Heres an example of the interface:

Reading the .wav files from the resource file:

namespace YolkRoll3._0
    public partial class YolkRollMain : Form
        int bankRoll;
        Random RandNum = new Random();
        SoundPlayer stopWav;
        SoundPlayer payoutWav;
        SoundPlayer screamWav;
        SoundPlayer explosionWav;
        int[] finalResult = new int[4];

        public YolkRollMain()

            // Loads sound files from YolkRollResource.resx
            stopWav = new SoundPlayer(YolkRoll3._0.YolkRollResource.Stop);
            payoutWav = new SoundPlayer(YolkRoll3._0.YolkRollResource.Payout);
            screamWav = new SoundPlayer(YolkRoll3._0.YolkRollResource.Scream);
            explosionWav = new SoundPlayer(YolkRoll3._0.YolkRollResource.Explosion);
            this.StartPosition = FormStartPosition.CenterScreen;

Playing the .wav:

private void timer1Stop_Tick(object sender, EventArgs e)
            // Stop spinning of first reel
            timer1Stop.Enabled = false;
            finalResult[1] = NewIndex();
            reelSlot1.Image = ilreelImages.Images[finalResult[1]];

Any idea why it runs perfectly during debug but gives an error message "The Wave Header is Corrupt"? stopWav plays once then the stopWav sound for the following reels fail.

Normally you'd get a resource using myProject.Properties.Resources.<resourcename> . Are you including the resource file in the executable? I'm not sure if the Express edition automatically uses the /resource compile option, you might need to use resgen.exe

This article has been dead for over six months. Start a new discussion instead.