title: InvalidCastException: Specified cast is not valid Error when tried to fetch image from url
body: <p>I am trying to fetch a image texture from </p>
  
  <pre><code>IEnumerator GetRequest1(string uri)
  {
      using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
      {
          yield return webRequest.SendWebRequest();
          img = ((DownloadHandlerTexture)webRequest.downloadHandler).texture;      
      }
  }
  </code></pre>
  
  <p>and passing it to a GUI</p>
  
  <pre><code>void OnGUI()
  {
      GUILayout.BeginArea(new Rect(100, 50, 500, 500));
      GUILayout.Label(img);
      GUILayout.EndArea();
  }
  </code></pre>
  
  <p>on it should have worked previous days it was, today with some modifications its hitting error ,<a href="https://forum.unity.com/threads/editor-bug-invalidcastexception-specified-cast-is-not-valid.710021/" rel="nofollow noreferrer">tried this </a> and much more, but could not get helped. It would be great if I get a hint. thank you</p>
  
  <p>i am using same method somewere else but thats perfect , in here its hitting error as </p>
  
  <blockquote>
    <p>InvalidCastException: Specified cast is not valid.
    gettiles+d__25.MoveNext () (at Assets/Scripts/gettiles.cs:111)UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)</p>
  </blockquote>
  
  <p>an InvalidCastException error Hits in case where the actual type of the data doesn't match the type which was passed But here it is sprite to sprite</p>
  
  <blockquote>
    <p>specificimage.sprite = Sprite.Create(((DownloadHandlerTexture)webRequest.downloadHandler).texture, new Rect(0, 0, 250,250).texture.height), new Vector2(0.5f, 0.5f)); </p>
  </blockquote>