Jump to content
  • Advertisement
Sign in to follow this  
Phil123

XNA Access Violation Exception

This topic is 2054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=Microsoft.Xna.Framework
  StackTrace:
       at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.IsEventRegistered(EventType type)
       at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.UnregisterEvent(EventType type)
       at Microsoft.Xna.Framework.Audio.KernelMicrophone.ShutdownCaptureEngine()
       at Microsoft.Xna.Framework.Audio.MicrophoneUnsafeNativeMethods.ShutdownCaptureEngine()
       at Microsoft.Xna.Framework.Audio.AudioRendererShutdownHandler.AppExitingEventHandler(Object sender, EventArgs args)
  InnerException:
 

Every now and then, I get a System.AccessViolationException when closing the program and all the information I'm given is above.  I suppose it isn't really an issue as if the program crashes when I'm closing it, so it probably isn't the absolute end of the world (compared to it crashing during run time).  But I still would prefer for this to not happen.  Unfortunately, I don't know what's directly causing it, and I'm not sure it'd be helpful to post my audio manager classes either since the problem seems to be within the framework itself.

 

Any ideas?

Share this post


Link to post
Share on other sites
Advertisement

iirc a Sound effect must be properly disposed of when exiting.

 

So in the following Function (given to you by XNAs Game class:

 

private void UnloadContent(...)
{
    SoundEffect.Dispose();
}

Share this post


Link to post
Share on other sites

Are you doing any multi-threading?

 

Negative.

 

 

iirc a Sound effect must be properly disposed of when exiting.

 

So in the following Function (given to you by XNAs Game class:

 

 

private void UnloadContent(...)
{
    SoundEffect.Dispose();
}

 

Yeah, I'm still getting the same Access Violation Exception despite doing this on all of the sound/music content that's in the game.

 

 

Clicky!.

 

No luck with these solutions either. 

Share this post


Link to post
Share on other sites

As the error says, you cannot really do much. That is, unless you have relevant source codes (e.g. to XNA)

 

Yeah, it is annoying during debugging, but the end user will probably never experience it, unlike the poor dev who quits the game three hundred times during a weekend...

 

I can share what helped me to reduce the occurence to a minimum - Put a 3-second wait time before the game actually exits. This, most of the time, helps and it reduced the crashing from few hundred times to few tens for me...

 

Some people reportedly experienced another reduction of crashes when prolonging 3 seconds to 5. Didn't work for me, but you could try. 5 seconds, for me, is way too much time to wait till I can interact with Visual Studio...

Share this post


Link to post
Share on other sites

Ack.  Well, I'm thinking of just running it without debugging, as most of the work I'm doing is tweaking (and not exception-fixing).  Thanks for the responses everyone.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!