Rendering to image shouldn't crash when referenced images can't load
It would be nice if ImageRenderer handled unresolved urls a little more gracefully...
Here's the hack that I added to \AdaptiveCards\source\dotnet\Library\AdaptiveCards.Xaml.WPF\Rendering\ImageRenderer.cs for my purposes in case it helps.
protected async Task GetImage(string url)
{
using (WebClient client = new WebClient())
{
byte[] data;
try
{
data = await client.DownloadDataTaskAsync(url).ConfigureAwait(false);
}
catch (Exception ex)
{
// Return a transparent 1x1 pixel PNG when there is a problem
data = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=");
}
lock (Images)
Images[url] = data;
}
}
Repro:
- create a card with some image that has a bad url
- Render it to an image... ImageRenderer renderer = new ImageRenderer(new HostConfig(), String.Empty); Stream stream = await renderer.RenderAdaptiveCardAsync(card, 600);
Expected: to get something back with placeholders or even just with the image missing
Actual: the card is not rendered at all (no image) -- library internally has an uncaught exception
@almedina-ms can you pick this up?
I think this issue doesn't repro anymore

@qpongo can you please check with our latest 1.2.0 bits whether this issue still repro's for you? Thanks.