I have a code for checking if response is error 404 an if it is set an image from resources that code works fine before but now it is giving error I don't know why. Here is the code
try
{
picture.Load(img);
}
catch (WebException we)
{
HttpWebResponse errorResponse = we.Response as HttpWebResponse;
if (errorResponse.StatusCode == HttpStatusCode.NotFound)
{
Image image = Properties.Resources.Error_404;
picture.Image = image;
}
}
the HttpStatusCode,NotFound is what gives error Object reference not set to an instance of an object C#.