Search code examples
c#monogametexture2d

MonoGame Texture2D initialisation by OpenFileDialog


At the moment I develop a C# WPF application to create Item, Creatures and Maps for a MonoGame 2D RPG project. In my solution Items contains a Textur2D object.

Now I try to fill the Texture2D object from a OpenFileDialoge (an image on my HDD). But if I try to fill the Texture2D property I got every time follow exception:

enter image description here In my example I tried to figure out the problem by breaking down the initialisation of the Texture2D object in the lowest form. So I find out, that problem is made by the initialisation from a new GraphicsDevice object.

At last I tried to add the "System.Runtime.WindowsRuntime" library by nuget but then I got follow exception:

enter image description here

Got anyone a tipp how I can fix it? I spend so much time to fix this problem with out any result.


Solution

  • I got a solution.

    The reference to the MonoGame.Framework.dll was corrupt. I deleted the MonoGame.Framework.dll form the references and add them from my MonoGame project.