   XNA null error with sound
  I'm working out of beginning XNA 2.0 game programming and i'm working on the RockRain game if anyone is familiar with that.forgive me for the long source, i'll only post 2 of the 4 files as the other 2 have no audio in them, and the application was working before audio was added.anyways my error stems from this section of code   public void PlayCue(string cue)   {  soundBank.PlayCue(cue);   }Game1.cs-------using System;using System.Collections.Generic;using System.Linq;using Microsoft.Xna.Framework;using Microsoft.Xna.Framework.Audio;using Microsoft.Xna.Framework.Content;using Microsoft.Xna.Framework.GamerServices;using Microsoft.Xna.Framework.Graphics;using Microsoft.Xna.Framework.Input;using Microsoft.Xna.Framework.Media;using Microsoft.Xna.Framework.Net;using Microsoft.Xna.Framework.Storage;namespace RockRain{    /// <summary>    /// This is the main type for your game    /// </summary>    public class Game1 : Microsoft.Xna.Framework.Game    {   GraphicsDeviceManager graphics;   SpriteBatch spriteBatch;   private Texture2D backgroundTexture;   private Texture2D meteorTexture;   private Ship player;   private const int STARTMETEORCOUNT = 10;   private const int ADDMETEORTIME = 5000;   private int lastTickCount;   private int rockCount;   private AudioComponent audioComponent;   public Game1()   {  graphics = new GraphicsDeviceManager(this);  Content.RootDirectory = "Content";    // Background texture} /// <summary>   /// Allows the game to perform any initialization it needs to before starting to run.   /// This is where it can query for any required services and load any non-graphic   /// related content.  Calling base.Initialize will enumerate through any components   /// and initialize them as well.   /// </summary>   protected override void Initialize()   {  audioComponent = new AudioComponent(this);  Components.Add(audioComponent);  //start the background music  audioComponent.PlayCue("backmusic");  base.Initialize();   }   /// <summary>   /// LoadContent will be called once per game and is the place to load   /// all of your content.   /// </summary>   protected override void LoadContent()   {  // Create a new SpriteBatch, which can be used to draw textures.  spriteBatch = new SpriteBatch(GraphicsDevice);  backgroundTexture = Content.Load<Texture2D>("SpaceBackground");  meteorTexture = Content.Load<Texture2D>("RockRain"); // Add the SpriteBatch service  Services.AddService(typeof(SpriteBatch), spriteBatch);   }  // TODO: use this.Content to load your game content here   /// <summary>   /// UnloadContent will be called once per game and is the place to unload   /// all content.   /// </summary>   protected override void UnloadContent()   {  // TODO: Unload any non ContentManager content here   }   /// <summary>   /// Allows the game to run logic such as updating the world,   /// checking for collisions, gathering input, and playing audio.   /// </summary>   /// <param name="gameTime">Provides a snapshot of timing values.</param>   protected override void Update(GameTime gameTime)   {  // Allows the game to exit  GamePadState gamepadstatus = GamePad.GetState(PlayerIndex.One);  KeyboardState keyboard = Keyboard.GetState();  // allows game exit  if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) || (keyboard.IsKeyDown(Keys.Escape)))  { Exit();  }  // start if not started yet  if (player == null)  { Start();  }    // Call on game logic  DoGameLogic();  // update all other components  base.Update(gameTime);   }   /// <summary>   /// This is called when the game should draw itself.   /// </summary>   /// <param name="gameTime">Provides a snapshot of timing values.</param>   protected override void Draw(GameTime gameTime)   {  GraphicsDevice.Clear(Color.CornflowerBlue);  // TODO: Add your drawing code here  spriteBatch.Begin();  spriteBatch.Draw(backgroundTexture, new Rectangle(0, 0,    graphics.GraphicsDevice.DisplayMode.Width,    graphics.GraphicsDevice.DisplayMode.Height),    Color.LightGray);  spriteBatch.End();  // Start rendering sprites  spriteBatch.Begin(SpriteBlendMode.AlphaBlend);  // Draw the game components (sprites included)  base.Draw(gameTime);  // End rendering sprites  spriteBatch.End();   }   /// <summary>   /// Initialize the game round   /// </summary>   private void Start()   {  // create (if necessary) and put the player in start postition  if (player == null)  { // Add the player component player = new Ship(this, ref meteorTexture); Components.Add(player);  }  player.PutinStartPosition();  // Add the meteors  for (int i = 0; i < STARTMETEORCOUNT; i++)  { Components.Add(new Meteor(this, ref meteorTexture));  }  // Initialize a counter  lastTickCount = System.Environment.TickCount;  //reset rock count  rockCount = STARTMETEORCOUNT;   }   /// <summary>   /// Run the game logic   /// </summary>   private void DoGameLogic()   {  // Check collisions  bool hasCollision = false;  Rectangle shipRectangle = player.GetBounds();  foreach (GameComponent gc in Components)  { if (gc is Meteor) {hasCollision = ((Meteor)gc).CheckCollision(shipRectangle);if (hasCollision){    // Remove all previous meteors    RemoveAllMeteors();    // Lets start again    audioComponent.PlayCue("explosion");    Start();    break;} }  }   }   /// <summary>   /// Remove all meteors   /// </summary>   private void RemoveAllMeteors()   {  for (int i = 0; i < Components.Count; i++)  { if (Components is Meteor) {Components.RemoveAt(i);i--; }  }   }   /// <summary>   /// Check if it is time for a new rock!   /// </summary>   private void CheckforNewMeteor()   {  // Add a rock each ADDMETEORTIME  if ((System.Environment.TickCount - lastTickCount) > ADDMETEORTIME)  { lastTickCount = System.Environment.TickCount; Components.Add(new Meteor(this, ref meteorTexture)); rockCount++; audioComponent.PlayCue("newmeteor");  }   }    }}AudioComponent.cs-----------------#region Using Statementsusing System;using System.Collections.Generic;using Microsoft.Xna.Framework;using Microsoft.Xna.Framework.Audio;#endregionnamespace RockRain{    /// <summary>    /// Handle the audio in the game    /// </summary>    public class AudioComponent : Microsoft.Xna.Framework.GameComponent    {   private AudioEngine audioEngine;   private WaveBank waveBank;   private SoundBank soundBank;   public AudioComponent(Game game)  : base(game)   {  // TODO: Construct any child components here   }   /// <summary>   /// Allows the game component to perform any initialization it needs to before starting   /// to run.  This is where it can query for any required services and load content.   /// </summary>   public override void Initialize()   {  // Initialize sound engine  audioEngine = new AudioEngine("Content\\audio.xgs");  waveBank = new WaveBank(audioEngine, "Content\\Wave Bank.xwb");  if (waveBank != null)  { soundBank = new SoundBank(audioEngine, "Content\\Sound Bank.xsb");  }  base.Initialize();   }   /// <summary>   /// Allows the game component to update itself.   /// </summary>   /// <param name="gameTime">Provides a snapshot of timing values.</param>   public override void Update(GameTime gameTime)   {  // TODO: Add your update code here  audioEngine.Update();  base.Update(gameTime);   }   /// <summary>   /// Play a cue   /// </summary>   /// <param name="cue">cue to be played</param>   public void PlayCue(string cue)   {  soundBank.PlayCue(cue);   }    }}the exact error i am getting from debugging is:System.NullReferenceException was unhandled  Message="Object reference not set to an instance of an object."  Source="RockRain"  StackTrace:  at RockRain.AudioComponent.PlayCue(String cue) in F:\game stuff\causual game stuff\chapter 3\RockRain\RockRain\AudioComponent.cs:line 59  at RockRain.Game1.Initialize() in F:\game stuff\causual game stuff\chapter 3\RockRain\RockRain\Game1.cs:line 55  at Microsoft.Xna.Framework.Game.Run()  at RockRain.Program.Main(String[] args) in F:\game stuff\causual game stuff\chapter 3\RockRain\RockRain\Program.cs:line 14  InnerException: If you require the other two cs files please let me know.thanks for any and all help in advance.   
  As stupid as this is going to sound, call initialize() from your audio component into the constructor in that audio component. I have had issues ranging from 2.0 to present with the component manager not consistently calling initialize when i t is added to the component manager. If this works, it should create your sound/wavebanks properly.   ;  Rather than that, I'd suggest moving the first two lines in the Initialize to the constructor of the Game class.   