Jump to content
  • Advertisement
Sign in to follow this  

XNA: InvalidOperationException when loading models on 360

This topic is 3675 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

I posted this on the creators club forums, but didn't get any responses. Hoping someone here might know, so I'm reposting here. The original thread is here: We've got a loading thread to load in assets behind the loading screen. All it does at the moment load all the textures/models etc and then signal that it's done. The main thread just prints the text "Loading..." on screen, nothing more. Sometimes though (maybe about 30 - 40% of the time), we're getting an InvalidOperationException : This resource could not be created thrown. It's always on the same model, which is about a third of the way into our list of models. Before loading the models, it loads in some sprite textures too. Is there anything you have to take into consideration when loading in a separate thread to the main thread? Nothing is being created by the main thread during the load. Like I said, all it does is render some text that says "Loading..." with a sprite font that gets created in the LoadContent function. The loading thread gets kicked off in the Initialize function of the main Game class, after the call to base.Initialize(). Any ideas? It only seems to do it on 360, not Windows. I've posted the callstack if it'll be any help:
Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Graphics.VertexDeclaration.VertexDeclaration(Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice = {Microsoft.Xna.Framework.Graphics.GraphicsDevice}, Microsoft.Xna.Framework.Graphics.VertexElement[ elements = {Dimensions:[4]}) + 0x6b bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.VertexDeclarationReader.Read(Microsoft.Xna.Framework.Content.ContentReader input = {Microsoft.Xna.Framework.Content.ContentReader}, Microsoft.Xna.Framework.Graphics.VertexDeclaration existingInstance = null) + 0x71 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentReader.InvokeReader<Microsoft.Xna.Framework.Graphics.VertexDeclaration>(Microsoft.Xna.Framework.Content.ContentTypeReader reader = {Microsoft.Xna.Framework.Content.VertexDeclarationReader}, object existingInstance = null) + 0x23 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal<Microsoft.Xna.Framework.Graphics.VertexDeclaration>(object existingInstance = null) + 0x40 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Graphics.Model.ReadVertexDeclarations(Microsoft.Xna.Framework.Content.ContentReader input = {Microsoft.Xna.Framework.Content.ContentReader}) + 0x15 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Graphics.Model.Read(Microsoft.Xna.Framework.Content.ContentReader input = {Microsoft.Xna.Framework.Content.ContentReader}) + 0xd bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ModelReader.Read(Microsoft.Xna.Framework.Content.ContentReader input = {Microsoft.Xna.Framework.Content.ContentReader}, Microsoft.Xna.Framework.Graphics.Model existingInstance = null)   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentReader.InvokeReader<Microsoft.Xna.Framework.Graphics.Model>(Microsoft.Xna.Framework.Content.ContentTypeReader reader = {Microsoft.Xna.Framework.Content.ModelReader}, object existingInstance = null) + 0x23 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal<Microsoft.Xna.Framework.Graphics.Model>(object existingInstance = null) + 0x40 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentReader.ReadAsset<Microsoft.Xna.Framework.Graphics.Model>() + 0x7 bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentManager.ReadAsset<Microsoft.Xna.Framework.Graphics.Model>(string assetName = "Content\\Models\\Block_PS135_Y", System.Action<System.IDisposable> recordDisposableObject = null) + 0x3a bytes   
  Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Content.ContentManager.Load<Microsoft.Xna.Framework.Graphics.Model>(string assetName = "Content\\Models\\Block_PS135_Y") + 0x85 bytes   
> Game360.exe!GameBB.CXnaApplication.LoadModels(string Filename = "Content\\Config\\Models.xml") Line 470 + 0x15 bytes C#  
  Game360.exe!GameBB.CXnaApplication.LoadGameContent() Line 524 + 0xb bytes C#  

Share this post

Link to post
Share on other sites
To my best knowledge it's only safe to use a ContentManager with the thread that was used to create it. If you want to make a loading thread, you need to make a new ContentManager with that thread and only use that.

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!