craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 325 forks source link

`InvalidCastException` thrown when loading a `TiledMap` #728

Open craxal opened 3 years ago

craxal commented 3 years ago

Using 3.8.0, I'm trying to leverage MonoGame.Extended for Tiled maps and tilesets. I've got the MGCB editor all set up and successfully building my Tiled map and tileset. However, when I launch my game:

Content.Load<TiledMap>("TestMap");
System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'MonoGame.Extended.Tiled.TiledMap'.'
   at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance)
   at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
   at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
   at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
   at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
   ...

Seems odd the object being returned by TiledMapReader would be a string and not a TiledMap. Am I doing something wrong, or is there a bug somewhere?

As a side note, this problem doesn't reproduce if I build from source on my own.