Pergunta

I've got a strange issue that's left me scouring Google for the past couple of hours, but I haven't found anything even close to this.

I have a VB.NET Winforms project containing a class that dynamically generates an image URL for a remotely hosted charting API, and returns the URL as the source to a PictureBox (pbCallChart.ImageLocation = MyURL). This has been in place and working fine for years now. However, I recently had to upgrade the project from .NET 3.5 to .NET 4.0 (I'm working in VS 2010 on a 64-bit build, which apparently won't let you do active debug in .NET 3.5). As soon as I did this, my image stopped showing up.

I verified that the image works when I pull up the URL in a web browser on the same machine that I'm working from. At first I figured maybe that property was removed in 4.0, so I tried switching to the Load() function. No dice. Then I took it one step further and wrote this little function:

Public Function ChartImage() As Bitmap
        Dim ChartURL As String = "http://www.anyURL.com/img.jpg" 'Chart()
        Return New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(ChartURL)))
End Function

When I run this (and I've confirmed that it doesn't matter what URL I pass it), I always get the error:

An unhandled exception of type 'System.Net.WebException' occurred in System.dll

Additional information: Unable to connect to the remote server

I know this isn't a proxy problem, because it works fine on this same computer under .NET 3.5. And I've confirmed it's not just a debugging quirk, because I compiled executables and provided them to users - they confirmed that the .NET 3.5 version works and the .NET 4.0 version does not.

I can only assume that there must be some security configuration difference in the two versions that I don't know about, but it seems like someone would have mentioned it somewhere. Has anyone else ever experienced anything like this? I'm pretty much out of ideas - do you have any?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top