I've tried to do the same in C#
var wc = new WebClient();
wc.DownloadStringCompleted += (s, e) => Message.Text = e.Result;
wc.DownloadStringAsync(new Uri("http://google.com"));
Which actually gives me the same result but I do get to see the error once
in a while. It's saying something about SecurityException.
So I went on and tried fetching the page it with a webrequest
var wr = WebRequest.Create("http://google.com");
wr.BeginGetResponse(ar =>
{
var req = (WebRequest)ar.AsyncState;
var resp = req.EndGetResponse(ar);
using(var sr = new
StreamReader(resp.GetResponseStream()))
{
var result = sr.ReadToEnd();
Message.Text = result;
}
}, null);
This last approach also fails because AsyncState is null.
Have I lost my mind? Am I doing something wrong or is it Silverlight?
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
On Sat, Jun 27, 2009 at 9:58 AM, Ivan Porto Carrero <[email protected]>wrote:
> Hi
> I have a hard time understanding why the following won't work. I started
> with the following xaml:
>
> <UserControl x:Class="System.Windows.Controls.UserControl"
> xmlns="http://schemas.microsoft.com/client/2007"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
>
> <Grid x:Name="layout_root" Background="White">
> <TextBlock x:Name="message" FontSize="10" />
> </Grid>
>
> </UserControl>
>
> and in the initialize method of App I've got the following code
>
> @root = Application.current.load_root_visual(UserControl.new, "app.xaml")
> request = Net::WebClient.new
> request.download_string_completed do |sender, args|
> @root.find_name("message").text = "Completed"
> end
> request.download_string_async Uri.new("http://google.com")
>
>
> This works but as you can see nothing interesting happens except for that
> download_string_completed is called because the message textbloc shows
> Completed
>
> @root = Application.current.load_root_visual(UserControl.new, "app.xaml")
> request = Net::WebClient.new
> request.download_string_completed do |sender, args|
> @root.find_name("message").text = *args.result*
> end
> request.download_string_async Uri.new("http://google.com")
>
> But as soon as I ask the args for the result nothing happens anymore. it
> must be an exception somewhere but I have no idea as to where I can find the
> exception or stacktrace because all it does is show me a blank page with all
> layout removed and the IronRuby Console in the bottom is still there but it
> is disabled too.
>
> So how do I get to that error?
>
> ---
> Met vriendelijke groeten - Best regards - Salutations
> Ivan Porto Carrero
> Blog: http://flanders.co.nz
> Twitter: http://twitter.com/casualjim
> Author of IronRuby in Action (http://manning.com/carrero)
>
>
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core