[Mono-dev] Internet code which is fine under .NET, but dies on mono
Paul Johnson
paul at all-the-johnsons.co.uk
Fri Mar 11 07:56:58 EST 2011
Hi,
I have a bit of a problem with some come which works and builds fine under
VS2010 (targetting .NET 2) but returns a problem under mono on my linux box
(using 2.10.1) - here is the code
<--
private void btnTranslate_Click(object sender, EventArgs e)
{
string result = string.Empty;
string url = string.Format("
https://www.googleapis.com/language/translate/v2?key={0}&q={1}&source={2}&target={3}
",
key, txtTranslate.Text, data.from, data.to);
try
{
WebRequest req = HttpWebRequest.Create(url);
if (data.useproxy == true)
{
WebProxy myproxy = new WebProxy(data.proxyval,
data.proxyPort);
myproxy.BypassProxyOnLocal = false;
req.Proxy = myproxy;
}
req.Method = "GET";
using (WebResponse res = req.GetResponse())
{
using (StreamReader sr = new
StreamReader(res.GetResponseStream(), Encoding.UTF8))
{
result = sr.ReadToEnd();
}
}
}
catch (Exception er)
{
MessageBox.Show(er.Message, "Network error",
MessageBoxButtons.OK);
return;
}
-->
The code will fire up fine under mono, but fails to communicate with the
google service complaining that it was able decode the returned string or
the end of the string has been found,
Any ideas or do I need to put this into the mono BZ?
The binary can be found at http://www.all-the-johnsons.co.uk/translate.exe
TTFN
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110311/759aabd7/attachment.html
More information about the Mono-devel-list
mailing list