I have some code that creates an IWebProxy and then casts it to a WebProxy. I ran my program and it worked. Then I inserted a break point and it all of a sudden stopped working and gives me the error: "Unable to cast object of type 'WebProxyWrapperOpaque' to type 'System.Net.WebProxy'."
Another thing is that we use this method in 2 other programs. I ran these programs and there was no issue with the cast.
Why did it change all of a sudden? What happened to break it? I did nothing to the code and now it's permanently broken.
How do I fix this? I have to use the IWebProxy object because it's returned from a method in code that is not my code (otherwise I'd change it), but in the end I need to use a WebProxy.
EDIT: Here's some code...
public IWebProxy ToIWebProxy(string targetAddress)
{
//Does some proxy validation then returns an IWebProxy
}
somewhere else in the code I do this...
WebProxy myProxy = (WebProxy)(ToWebProxy(myAddress));
even tried this...
IWebProxy myIWebProx = ToWebProxy(myAddress);
WebProxy myProx = (WebProxy)(myIWebProx);
Again, this worked 20 minutes ago.