Windows 8: WinRT Error – The given System.Uri cannot be converted into a Windows.Foundation.Uri

I was trying to directly set the source of an image to the path within the assembly. Previously you built up the Uri to include the assembly name and the path to the asset. Just like below but this now throws an error.

            // ;Component/ must all ways be present in the Uri below
            Uri uri = new Uri("VJComponent;Component/Assets/joystick.png", UriKind.Relative);
            BitmapImage bi = new BitmapImage();
            bi.UriSource = uri;

The given System.Uri cannot be converted into a Windows.Foundation.Uri

Replace the assembly name and ‘;Component/’ with ‘ms-appx:/’ and build the Uri as before.

            Uri uri = new Uri("ms-appx:/Assets/joystick.png");
            BitmapImage bi = new BitmapImage();
            bi.UriSource = uri;

To do the same but directly in the XAML instead of doing it programmatically you previously did this


Again replace the assembly name and ‘;Component/’ with ‘ms-appx:/’ and build the Uri as before.