Sign in to follow this  
Phil123

XNA Access Violation Exception

Recommended Posts

Phil123    1276

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
Andy474    694

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
Phil123    1276

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
VladR    722

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
Phil123    1276

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this