Search code examples
c#uwpsecondary-live-tile

C# UWP app crashes if SecondaryTile Imagesources are not from Assets folder


Basically I'm trying to make an UWP app to create Custom Tiles on Start Menu. The SecondaryTile is working when the Tile Images are from Assets folder like this.

Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");
Uri square30x30Logo = new Uri("ms-appx:///Assets/square30x30Tile-sdk.png");

But I have images in ApplicationData folders and trying to use the path like this:

Uri square150x150Logo = new Uri(Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "ImageSquare.png"));
Uri wide310x150Logo = new Uri(Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "ImageWide.png"));
Uri square310x310Logo = new Uri(Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "ImageLarge.png"));
Uri square30x30Logo = new Uri(Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "ImageTiny.png"));

But this way the app is crashing. The debugger isn't working either. Any solutions?


Solution

  • OK finally figured it out. In Addition to Andrew's answer, I had to change to using the LocalState folder instead of the TempState. Andrew directed in the right way to use ms-appdata, but for some reason ms-appdata:///temp/ returned error. but using ms-appdata:///Local/ solved the Issue.