line
_tiledMap = Content.Load<TiledMap>("samplemap");
return error “System.IO.EndOfStreamException: ‘Unable to read beyond the end of the stream.’”
Details:
System.IO.EndOfStreamException
HResult=0x80070026
Message=Unable to read beyond the end of the stream.
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowEndOfFileException()
at System.IO.BinaryReader.ReadString()
at MonoGame.Extended.Tiled.TiledMapReader.ReadProperties(ContentReader reader, TiledMapProperties properties)
at MonoGame.Extended.Tiled.TiledMapReader.ReadLayer(ContentReader reader, TiledMap map)
at MonoGame.Extended.Tiled.TiledMapReader.ReadGroup(ContentReader reader, TiledMap map)
at MonoGame.Extended.Tiled.TiledMapReader.ReadLayers(ContentReader reader, TiledMap map)
at MonoGame.Extended.Tiled.TiledMapReader.Read(ContentReader reader, TiledMap existingInstance)
at Microsoft.Xna.Framework.Content.ContentTypeReader`1.Read(ContentReader input, Object existingInstance)
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)
at Test3.Game1.LoadContent() in D:\MonoGameProjects\Test3\Game1.cs:line 33
at Test3.Game1.Initialize() in D:\MonoGameProjects\Test3\Game1.cs:line 28
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Program.<Main>$(String[] args) in D:\MonoGameProjects\Test3\Program.cs:line 3
File Content.mgcb
#-------------------------------- References --------------------------------#
/reference:MonoGame.Extended.Content.Pipeline.dll
/reference:MonoGame.Extended.dll
/reference:MonoGame.Extended.Tiled.dll
#---------------------------------- Content ---------------------------------#
File .csproj
<PackageReference Include="MonoGame.Extended" Version="3.9.0-alpha0079" />
<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.9.0-alpha0079" />
<PackageReference Include="MonoGame.Extended.Tiled" Version="3.9.0-alpha0079" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
Game1.cs
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended.Tiled;
using MonoGame.Extended.Tiled.Renderers;
using System.Reflection.PortableExecutable;
using System;
using Test3;
namespace Test3
{
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
TiledMap _tiledMap;
TiledMapRenderer _tiledMapRenderer;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
_tiledMap = Content.Load<TiledMap>("samplemap");
_tiledMapRenderer = new TiledMapRenderer(GraphicsDevice, _tiledMap);
_spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
_tiledMapRenderer.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
_tiledMapRenderer.Draw();
base.Draw(gameTime);
}
}
}