Raw assets load issue on Windows Phone 8!

Topics: Content Building and Deploying, Windows Phone 8
Nov 15, 2014 at 6:16 PM
Hey There,

No matter what I tried, I couldn't load a raw image file I added into the Contents folder (tried plist than the associated image file directly). If I put a processed xnb file, it works fine but with raw asset (png in my case), I get this error :

An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary

I downloaded v1.3 of WP8 template from VS Gallery and using VS2012. I also made sure that the files are marked as Content and copy if newer.

Is there any WP8 specific bug about this since I know that previously this method worked on a Windows desktop project that I worked.

Thanks in advance...

Dec 28, 2014 at 10:52 PM
Me too, raw asset is not working only in WP project...
Jan 9, 2015 at 7:37 AM
To give you an update, yes, it does not work and I did some workarounds but it made it work. If it doesn't load from the path, embed the thing as resource and try to load from there.
Jan 12, 2015 at 7:58 PM
Edited Jan 12, 2015 at 7:59 PM
Making .png file as "Resource" does not solve the problem. Ozden, could you please give more details about workaround?
Jan 12, 2015 at 11:24 PM
Hello! Happy Gregorian New Year to you all.

If you run the "texture 2d" test on your device, does the async texture loading test work? Those all load raw images.

When you load a raw image make sure you specify the ".png" suffix. Otherwise, it will try to always load XNB.
Jan 12, 2015 at 11:27 PM
For the record, I created a new test. This one loaded the cocos2d-xna badge from a png file. I deployed it to my windows phone 8.1 device and ran it. Worked like a charm..

make sure again you are using "myImage.png" as the FULLY QUALIFIED name.

Here is the test case that I created:

internal class RawTexture : TextureDemo
    private int m_nImageOffset;

    public override void OnEnter()

        m_nImageOffset = 0;

        CCSize size = CCDirector.SharedDirector.WinSize;

        CCLabelTTF label = new CCLabelTTF("Loading...", "Marker Felt", 32);
        label.Position = size.Center;
        AddChild(label, 10);

        CCScaleBy scale = new CCScaleBy(0.3f, 2);
        CCScaleBy scale_back = (CCScaleBy)scale.Reverse();
        CCSequence seq = new CCSequence(scale, scale_back);
        label.RunAction(new CCRepeatForever(seq));

        ScheduleOnce(LoadImages, 1.0f);

    public override void OnExit()

    private void LoadImages(float dt)
        var szSpriteName = "Images/powered.png";
        CCTextureCache.SharedTextureCache.AddImageAsync(szSpriteName, ImageLoaded);

    private void ImageLoaded(CCTexture2D tex)
        CCDirector director = CCDirector.SharedDirector;

        //CCAssert( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread");

        // IMPORTANT: The order on the callback is not guaranteed. Don't depend on the callback

        // This test just creates a sprite based on the Texture

        CCSprite sprite = new CCSprite(tex);
        sprite.AnchorPoint = CCPoint.Zero;
        AddChild(sprite, -1);

        CCSize size = director.WinSize;
        int i = m_nImageOffset * 32;
        sprite.Position = new CCPoint(i % (int)size.Width, (i / (int)size.Width) * 32);


    public override string title()
        return "Texture Async Load";

    public override string subtitle()
        return "Textures should load while an animation is being run";
Jan 13, 2015 at 7:44 AM
Well, first I need to correct it as an alternative way rather than workaround because I basically did convert png to xnb and it did get loaded.

I checked the files in my game and it seems I converted all image and sound/music files to xnb (just download and install vs 2010 express + xna 4 and compile your content in it) than all font, spritesheet and level definition files (plist and xml) as embedded resource.
Jan 13, 2015 at 9:19 AM
Edited Jan 13, 2015 at 9:23 AM
Thanks for very very fast reply:). @totallyevil, I will try this later, and let you know about results.
Jan 13, 2015 at 8:59 PM
Unfortunately I was unable to load img. My simple test here: http://1drv.ms/1IHXCl4
Jan 14, 2015 at 5:54 AM
Edited Jan 14, 2015 at 6:02 AM
powered.png should be placed in path "Content/Images/powered.png"

and set the property for him
Copy to Output Directory = Copy if newer
Marked as answer by totallyevil on 1/14/2015 at 8:17 AM
Jan 14, 2015 at 3:19 PM
Remember that in the XNA world you must put your content in the "Content" folder. That's where the default read will occur. If you have other paths for content, then you need to (1) mark that content as Content in Visual Studio and make it Copy if Newer, and then (2) add the new path to the search path in Cocos2D-XNA.

If you don't tell the framework where to look for your content, then it won't be able to find it. You can see how that works in the CCTexture2D class and also in the CCTextureCache class. When you add an image by file name it uses the search path to resolve where it might exist and then loads the first location that it finds. This is also how Cocos2D-X works.
Jan 14, 2015 at 5:51 PM
Edited Jan 14, 2015 at 6:13 PM
I have updated project http://1drv.ms/1IHXCl4 with @gena_m advice, but still same problem.
CCTexture2D tex property located in IntroLayer.cs is null.
Jan 14, 2015 at 7:51 PM
Make sure you update your nugget package references. Once I updated the cc2d-xna WP8 project refs the project worked as-is.

VS: Tools -> Nuget Package Manager -> Package Manager Settings
NuGet package Manager : Package Sources : Add "http://nuget.cocos2dxna.com/nuget"

Now you will get the updates that we post regularly .
Jan 14, 2015 at 8:31 PM
totallyevil wrote:
Make sure you update your nugget package references. Once I updated the cc2d-xna WP8 project refs the project worked as-is.

VS: Tools -> Nuget Package Manager -> Package Manager Settings
NuGet package Manager : Package Sources : Add "http://nuget.cocos2dxna.com/nuget"

Now you will get the updates that we post regularly .
Oh yeah:) I finally saw my sophisticated picture:) . Previously I have downloaded lib from default nuget source ( version 1.3..). Version from source you have mentioned works perfect. Thanks!