error loading png texture from file

Topics: Windows Phone 8
Aug 4, 2014 at 3:04 PM
hi,
i was using an old version of the library (build from sources on march) and the CCTexture2D.InitWithFile method worked correctly (I use it to load a png from file system). Now, with the current version of the library on github, this method fails only on WP (System.IO.FileNotFoundException). On the other platforms (iOS, Android, Windows DX) it's still all ok. I've tryied to revert to use the old cocos2d-xna version and works correctly also on WP (so it isn't a problem with my data/sources).
Someone has my same problem?

Thank you,

Stefano
Coordinator
Aug 4, 2014 at 9:58 PM
There has been a few changes in MonoGame for texture loading from streams. The FileNotFound exception sounds like a problem with the title container and you trying to use a non-relative URL for the texture. What stream URL are you trying to load?
Aug 5, 2014 at 10:31 AM
I've tryied every combination of path (moving image accordingly), inside and out Content folder, non-relative or relative ("atlases/mine.png", "/atlases/mine.png", "mine.png", "Content/atlases/mine.png", etc) with no success. In the old version (and still on other platforms) the right path is "atlases/mine.png", with "mine.png" in "/Content/atlases/mine.png" having Content.RootDirectory = "Content".

This is my stack trace:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in MonoGame.Framework.DLL
A first chance exception of type 'Microsoft.Xna.Framework.Content.ContentLoadException' occurred in MonoGame.Framework.DLL
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
ERROR! action will not invoke because the current dispatcher is not UI-thread compatible.
A first chance exception of type 'System.NullReferenceException' occurred in MonoGame.Framework.DLL
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in MonoGame.Framework.DLL
A first chance exception of type 'Microsoft.Xna.Framework.Content.ContentLoadException' occurred in MonoGame.Framework.DLL
ERROR! action will not invoke because the current dispatcher is not UI-thread compatible.
A first chance exception of type 'System.NullReferenceException' occurred in MonoGame.Framework.DLL
ERROR! action will not invoke because the current dispatcher is not UI-thread compatible.

Can be the problem related to "ERROR! action will not invoke because the current dispatcher is not UI-thread compatible."?
I try to load the png in the CCApplication.ApplicationDidFinishLaunching event.
Coordinator
Aug 5, 2014 at 4:07 PM
ERROR! action will not invoke because the current dispatcher is not UI-thread compatible.
This message occurs when the wait on the UI thread lock undergoes a timeout exception. There is a 750ms wait timeout for UI blocking threads. You will see this happen most often while debugging.

Make sure your project (VS or Xamarin Studio) has the "mine.png" file set to Content as the build action and set to copy always, or copy if newer.

Then look in the actual bin/Debug/Content directory and see if the file actually does exist there ...
Aug 6, 2014 at 8:35 AM
I've checked and the file exists in the right folder on the xap package. I've changed the code to read the file directly in byte[] and create the texture using InitWithData method; now I have no more the FileNotFoundException and the data is read correctly (the byte[] is filled with right data), but the texture seems invalid in some way (it's displayed only a white background). With the same sources and data, only changing the libraries to March version, the game starts correctly.
Do you have some suggestions? For now I think I'll use the older version..
Thank you!