This is a migrated thread and some comments may be shown as answers.

ImageColumn with binding on URL to a HTTP Resource: ArgumentNullException when Adress not available

3 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ClausDC
Top achievements
Rank 1
Iron
ClausDC asked on 10 Aug 2017, 07:01 AM

As the title says, when I bind an ImageColumn to a URL which points to a an image on the web, I get an exception in the event of the image not being available (for example if the server is down). Is there any way to prevent this?

Value cannot be null.
Parameter name: uriSource

at System.Windows.Media.Imaging.BitmapImage..ctor(Uri uriSource, RequestCachePolicy uriCachePolicy)
at Telerik.Windows.Controls.GridViewImageColumn.Image_ImageFailed(Object sender, ExceptionRoutedEventArgs e)

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 14 Aug 2017, 12:48 PM
Hello Claus,

I tested the behavior of the control locally and was not able to replicate  such NullReferenceException. When an image that is not present is provided as a source, an IOException is raised and internally caught. In the ImageFailed event there is a null check applied for the sender parameter. As only it should be able to raise a NullReferenceException, the behavior you are experiencing is quite strange. With this in mind, may I kindly ask you to share some additional details regarding the setup to reproduce the exception?

Regards,
Stefan X1
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
ClausDC
Top achievements
Rank 1
Iron
answered on 16 Aug 2017, 10:25 AM

I think the important bit is that it has to be a web address? Like for example "http://domain.com.../image.jpg". I had this workaround that I first check myself on the server if the image is available, if yes then I set the source to the URL, if no then I set it to "string.Empty", in any other case I got aforementioned exceptions. For obvious reasons, this is not a satisfying solution though (Performance, Image could still be no longer available after the check and before the load).

For now my solution was to no longer use ImageColumn but a normal DataColumn with an Image-Control in the CellTemplate which seems to work fine. I'm just wondering why the ImageColumn has these problems.

0
Stefan
Telerik team
answered on 21 Aug 2017, 09:26 AM
Hi Claus,

Thank you for the detailed update.

Indeed, checking the existence of a given image on the server before setting it as a source of GridViewImageColumn would not be appropriate. Unfortunately, I am still not able to replicate the exception on my end. In order to avoid any misunderstandings, may I kindly ask you to open a new support thread and attach a sample application that demonstrates the error in it? Thus, we will be able to investigate the case further.

Thank you in advance for your cooperation.

Regards,
Stefan X1
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
ClausDC
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
ClausDC
Top achievements
Rank 1
Iron
Share this question
or