[Ironruby-core] silverlight 3 question

Jimmy Schementi Jimmy.Schementi at microsoft.com
Mon Jun 29 01:44:57 EDT 2009


Yeah, the clientaccesspolicy.xml file requirement makes these things a bit annoying. This is why most JavaScript APIs are .js files hosted on the domain so they can make requests back to the domain.

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ivan Porto Carrero
Sent: Saturday, June 27, 2009 2:25 AM
To: ironruby-core
Subject: Re: [Ironruby-core] silverlight 3 question

k rookie mistake I guess. google.com<http://google.com> obviously doesn't have a crossdomainpolicy.xml file in place
Using the flickr url I wanted to get in the first place helps a lot.



---
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 10:32 AM, Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> wrote:
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 <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> 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)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090629/a1cfcbbc/attachment.html>


More information about the Ironruby-core mailing list