Yeah, I know what you think, probably something like "Don't you have wrong path? -_-" And I can assure you, I have right path. Not saying it was working all the time, but when the exception pops up, and I will choose to continue, the program normally continues like nothing happened. Even the images, which had "wrong path" were loaded and drawn correctly. Even though I think that there is something messed up in the actual Monogame I'll give you my codes:
Image class (only piece of code, the class is pretty big)
public float Alpha;
public String FontName, Text;
public String Path;
[XmlIgnore]
public Texture2D Texture;
public Vector2 Scale;
public Vector2 Position;
[XmlIgnore]
public Rectangle SourceRect;
public bool CenterScale;
public bool IsActive;
SpriteFont font;
Vector2 origin;
ContentManager content;
RenderTarget2D renderTarget;
Dictionary<String, ImageEffect> effectList;
public Image(String path) {
Initialize(path);
}
public Image () {
Initialize(String.Empty);
}
void Initialize(string path) {
Text = Path = String.Empty;
Path = path;
FontName = "Arial";
Position = Vector2.Zero;
Scale = Vector2.One;
Alpha = 1.0F;
SourceRect = Rectangle.Empty;
CenterScale = true;
effectList = new Dictionary<String, ImageEffect>();
}
public void LoadContent () {
content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Content");
if (Path != String.Empty)
Texture = content.Load<Texture2D>(Path); //error here
font = content.Load<SpriteFont>(FontName);
Vector2 dimensions = Vector2.Zero;
if (Texture != null)
dimensions.X += Texture.Width;
dimensions.X += font.MeasureString(Text).X;
if (Texture != null)
dimensions.Y += Math.Max(Texture.Height, font.MeasureString(Text).Y);
else
dimensions.Y += font.MeasureString(Text).Y;
if (SourceRect == Rectangle.Empty)
SourceRect = new Rectangle(0, 0, (int)dimensions.X, (int)dimensions.Y);
if (dimensions.X == 0)
dimensions.X++;
if (dimensions.Y == 0)
dimensions.Y++;
renderTarget = new RenderTarget2D(ScreenManager.Instance.GraphicsDevice, (int)dimensions.X, (int)dimensions.Y);
ScreenManager.Instance.GraphicsDevice.SetRenderTarget(renderTarget);
ScreenManager.Instance.GraphicsDevice.Clear(Color.Transparent);
ScreenManager.Instance.SpriteBatch.Begin();
if (Texture != null)
ScreenManager.Instance.SpriteBatch.Draw(Texture, Vector2.Zero, Color.White);
ScreenManager.Instance.SpriteBatch.DrawString(font, Text, Vector2.Zero, Color.White);
ScreenManager.Instance.SpriteBatch.End();
Texture = renderTarget;
ScreenManager.Instance.GraphicsDevice.SetRenderTarget(null);
}
And Image creation:
Background = new Image("Backgrounds/MenuBackground.png");
Background.LoadContent();
This is my Content folder:
I think I have canceled some "Symbol loading" or somethink like that in Visual Studio. Could this cause that exception?