I have Visual Studio 2010 and code in VB.NET. I wrote some software back in 2017-ish that has worked fine for the past 5 years. The program still works fine on the computer I wrote the software on. However, it has stopped working on all other computers. The problem is in my GetPicture code.
Function GetPicture(ByVal url As String) As Image
GlobalVariables.PictureError = False
Try
url = Trim(url)
url = ReplaceText(url, "https", "http")
Dim web_client As New WebClient()
Const IE8 As String = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648) "
web_client.Headers.Add("user-agent", IE8)
If Mid(url, 1, 5).ToLower <> "http:" Then url = "http:" & url
Dim image_stream As New _
MemoryStream(web_client.DownloadData(url))
Return Image.FromStream(image_stream)
web_client.Dispose()
Catch ex As Exception
GlobalVariables.PictureError = True
End Try
Return Nothing
End Function
I use this code to download pictures from the web. Here is a sample URL it would download from: http://img.gsmls.com/imagedb/highres/53/104300640_0.jpg
On the "other" computers, I am getting this error: "Could not create TSL/SSL secure channel." Based on my googling here, I have to change to TLS1.2, which VB.NET 2010 does not support. I guess the image server has been upgraded and now requires the new framework?
I am curious if anyone has any insight as to why this would still work on the computer I use to code the software, and if there's anything I could do to right this on the other computers? I would prefer to avoid updating to a new version of Visual Studio.
Thanks to Martheen for the solution:
ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)