craftworkgames / MonoGame.Extended

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

Microsoft.Xna.Framework.Content.ContentLoadException #816

Closed coinight closed 1 year ago

coinight commented 1 year ago

Sorry for disturbing you. I'm learning monogame,and i wanna load some texts which are created in tilemap editor, i noticed that the TiledMapObjectLayer's TiledMapObject WILL NOT load text property correctly(missing dictKey:Text,Font and so...) so i want to change some source code to load Text Obj correctly. i delete the nuget package,import the source code, start program. It happened:

in line: map = Globals.contentManager.Load("TileMap\MainMap"); Microsoft.Xna.Framework.Content.ContentLoadException HResult=0x80131500 Message=Could not find ContentTypeReader Type. Please ensure the name of the Assembly that contains the Type matches the assembly in the full type name: MonoGame.Extended.Tiled.TiledMapReader, MonoGame.Extended.Tiled (MonoGame.Extended.Tiled.TiledMapReader, MonoGame.Extended.Tiled) Source=MonoGame.Framework StackTrace: in Microsoft.Xna.Framework.Content.ContentTypeReaderManager.LoadAssetReaders(ContentReader reader) in Microsoft.Xna.Framework.Content.ContentReader.InitializeTypeReaders() in Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() in Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject) in 在 Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) in Engine.Scene..ctor() 在 D:\MonoGames\MyFirstMonoGame\MyFirstMonoGame\Engine\Scene.cs in MyFirstMonoGame.Main.LoadContent() in D:\MonoGames\MyFirstMonoGame\MyFirstMonoGame\Main.cs line:42 in MyFirstMonoGame.Main.Initialize() in D:\MonoGames\MyFirstMonoGame\MyFirstMonoGame\Main.cs line:34 in Microsoft.Xna.Framework.Game.DoInitialize() in Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) in MyFirstMonoGame.Main.Program.Main() in D:\MonoGames\MyFirstMonoGame\MyFirstMonoGame\Main.cs line:78

why it happened?And how to solve it. I'm chaning Engine form unity to monogame,so maybe it's a sally question,but i have no idea. thanks

Gandifil commented 1 year ago

Hello! I'm glad you pay attention to our project. Do you mean you've removed nuget reference to MonoGame.Extended.Tiled and created your own version of MonoGame.Extended.Tiled? Or you only copy source code of MonoGame.Extended.Tiled to main project?

coinight commented 1 year ago

I removed nuget reference to MonoGame.Extended(removed all included pipeline,tilemap and so on),and add all source code to my project. the error report on content Load,but I had changed nothing in code ,why the content can't be loaded?

Gandifil commented 1 year ago

Because, when you add source code to your project, you change assembly name. In error message you can read this: MonoGame.Extended.Tiled.TiledMapReader, MonoGame.Extended.Tiled (from content). It means engine try to search class with name MonoGame.Extended.Tiled.TiledMapReadera inside assembly MonoGame.Extended.Tiled.

You can try to create own assembly MonoGame.Extended.Tiled in your solution and copy class TiledMapReader. Don't change namespace.

coinight commented 1 year ago

Thanks! i will try it later

frits191 commented 3 weeks ago

Sorry for re-opening, but currently experiencing this exact problem with 4.0.3. @coinight If possible, would you mind sharing what you did to get it to load? I'm not sure how this new assembly should look like, just the TiledMapReader class? Not the whole folder? Any help would be greatly appreciated!