Forum: IronRuby silverlight 3 question

Posted by Ivan Porto carrero (casualjim)
on 2009-06-27 09:59
(Received via mailing list)
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)
Posted by Ivan Porto carrero (casualjim)
on 2009-06-27 10:50
(Received via mailing list)
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)
Posted by Ivan Porto carrero (casualjim)
on 2009-06-27 11:38
(Received via mailing list)
k rookie mistake I guess. google.com obviously doesn't have a
crossdomainpolicy.xml file in placeUsing 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)
Posted by Jimmy Schementi (Guest)
on 2009-06-29 07:45
(Received via mailing list)
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@rubyforge.org 
[mailto:ironruby-core-bounces@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@flanders.co.nz<mailto:ivan@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@flanders.co.nz<mailto:ivan@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)
Posted by Ivan Porto carrero (casualjim)
on 2009-06-29 10:30
(Received via mailing list)
What kept me most busy was the fact that I never got any error messages
displayed to me, which left as only option to comment out code until i 
could
see something again.
I have a xaml that shows a background color. When an error occurs in the
ruby code the background would become white. the REPL console doesn't 
accept
any input anymore and I have no clue as to what's going on.  So 
sometimes I
could write the code in C# and see why things were failing.

I must be missing something as I do have the following as params 
debug=true,
console=true

<param name="initParams" value="debug=true, reportErrors=errorLocation,
console=true" />

So how do I see errors when they occur?


---
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 Mon, Jun 29, 2009 at 7:44 AM, Jimmy Schementi <
Posted by Jimmy Schementi (Guest)
on 2009-06-29 10:43
(Received via mailing list)
Is the Silverlight control taking up the whole HTML window? If so, make 
sure to do <params name="windowless" value="true" /> so the error 
console shows up over the Silverlight app.

If this doesn’t seem to fix it, mind sending me a repro?

From: ironruby-core-bounces@rubyforge.org 
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto 
Carrero
Sent: Monday, June 29, 2009 1:18 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] silverlight 3 question

What kept me most busy was the fact that I never got any error messages 
displayed to me, which left as only option to comment out code until i 
could see something again.

I have a xaml that shows a background color. When an error occurs in the 
ruby code the background would become white. the REPL console doesn't 
accept any input anymore and I have no clue as to what's going on.  So 
sometimes I could write the code in C# and see why things were failing.

I must be missing something as I do have the following as params 
debug=true, console=true

<param name="initParams" value="debug=true, reportErrors=errorLocation, 
console=true" />

So how do I see errors when they occur?


---
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 Mon, Jun 29, 2009 at 7:44 AM, Jimmy Schementi 
<Jimmy.Schementi@microsoft.com<mailto:Jimmy.Schementi@microsoft.com>> 
wrote:

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@rubyforge.org<mailto:ironruby-core-bounces@rubyforge.org> 
[mailto:ironruby-core-bounces@rubyforge.org<mailto:ironruby-core-bounces@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@flanders.co.nz<mailto:ivan@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@flanders.co.nz<mailto:ivan@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)





_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.