Importer 'TiledMapTilesetImporter' had unexpected failure!

So, I was working on getting a project using Tiled up and running. Everything seems to be working fine, but I am unable to build my project. The following exception is thrown:

  System.NullReferenceException: Object reference not set to an instance of an object.
     at MonoGame.Extended.Content.Pipeline.Tiled.TiledMapTilesetImporter.DeserializeTiledMapTilesetContent(String filePath, ContentImporterContext context)
     at MonoGame.Extended.Content.Pipeline.Tiled.TiledMapTilesetImporter.Import(String filePath, ContentImporterContext context)
     at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\ContentImporter.cs:line 45
     at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\Builder\PipelineManager.cs:line 669

If I remove <tileset firstgid="1" source="Mushy_flooring.tsx"/> from my mapā€™s .tmx file, it builds fine. But of course, the map now does not display anything.
Iā€™ve tried numerous ways to solve this issue, including; making the tileset embedded in the map, re-locating the .png assets, and trying to create a fresh new project.

btw, this is on Ubuntu Linux using Visual Studio Code.

I would really appreciate any help again guys.

Could you post your project? If you donā€™t want to share here you can find the MG.Ex Discord and DM me.

UPDATE: was messing around and found the issue.
I changed my mapsā€™ tileset from a ā€˜collection of imagesā€™ to ā€˜based on tileset imageā€™.
The error wasnā€™t with the .tmx file, but rather the .tsx (tileset file). For whatever reason, the tileset being a collection of images rather than just one causes the error.

For reference, here is the .tsk file:

<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.4" tiledversion="1.4.2" name="flooring" tilewidth="64" tileheight="64" tilecount="24" columns="8">
 <grid orientation="isometric" width="64" height="64"/>
 <image source="flooring.png" trans="ffffff" width="512" height="192"/>
</tileset>

and here is a .tsk file using the ā€˜collection of images option in Tiledā€™:

Click Here
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.4" tiledversion="1.4.2" name="Mushy" tilewidth="64" tileheight="64" tilecount="24" columns="0">
 <grid orientation="orthogonal" width="1" height="1"/>
 <tile id="0">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_539_0000-10.png"/>
 </tile>
 <tile id="1">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_539_0000-16.png"/>
 </tile>
 <tile id="2">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_539_0000-20.png"/>
 </tile>
 <tile id="3">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_539_0000-31.png"/>
 </tile>
 <tile id="4">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_619_0000-16.png"/>
 </tile>
 <tile id="5">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_619_0000-22.png"/>
 </tile>
 <tile id="6">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_619_0000-41.png"/>
 </tile>
 <tile id="7">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_659_0000-9.png"/>
 </tile>
 <tile id="8">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_879_0000-54.png"/>
 </tile>
 <tile id="9">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1119_0000-45.png"/>
 </tile>
 <tile id="10">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1299_0000-10.png"/>
 </tile>
 <tile id="11">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1379_0000-6.png"/>
 </tile>
 <tile id="12">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1379_0000-39.png"/>
 </tile>
 <tile id="13">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1379_0000-47.png"/>
 </tile>
 <tile id="14">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1459_0000-50.png"/>
 </tile>
 <tile id="15">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1479_0000-29.png"/>
 </tile>
 <tile id="16">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1559_0000-33.png"/>
 </tile>
 <tile id="17">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1599_0000-39.png"/>
 </tile>
 <tile id="18">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1679_0000-14.png"/>
 </tile>
 <tile id="19">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1679_0000-30.png"/>
 </tile>
 <tile id="20">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1679_0000-43.png"/>
 </tile>
 <tile id="21">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1699_0000-57.png"/>
 </tile>
 <tile id="22">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1859_0000-26.png"/>
 </tile>
 <tile id="23">
  <image width="64" height="64" source="Mushy_Individual_Tiles/flooring/train_1859_0000-43.png"/>
 </tile>
</tileset>

UPDATE 2: Iā€™m having to use assets I bought for my game, unfortunately, they are all different sizes. Making them 1 file wonā€™t work.

Is there any update as to how I can use a tileset with Collection of images? Iā€™ve read other forum posts about the same issue, but none of them work (or they just used 1 file for the tileset).

For future travellers: I had this issue as well, and can confirm that merging my tiles into a single tilesheet and setting up the tileset in Tiled as ā€œbased on a tileset imageā€ instead of ā€œcollection of imagesā€ did resolve it (since my tiles are of a regular size).

If your tiles are of different sizes, maybe you could use multiple tilesets? Iā€™ve only just started with Tiled, but it seems to support a map using tiles from multiple tilesets, so if you create a new one for each size of tile you have, that might get around this issue. Although hopefully, in the future it will not be an issue!

1 Like

Thanks, this really helped me.