Forum: IronRuby defined?(xxx) behaves differently when called from Silverlight

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 Thibaut Barrère (thbar)
on 2009-04-02 00:28
(Received via mailing list)
Hi,

I noticed something that I didn't expect while working with Silverlight.

defined?(System::Windows::Forms::Control)

throws an exception:

MemberAccessException: uninitialized constant System::Windows::Forms
   à IronRuby.Builtins.ModuleOps.ConstantMissing(RubyModule self, String
name)
   à _stub_$2##1(Closure , CallSite , CodeContext , RubyModule , SymbolId
)
   à System.Scripting.Actions.MatchCaller.Call3[T0,T1,T2,TRet](Func`5
target, CallSite site, Object[] args)
   à System.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   à System.Scripting.Actions.UpdateDelegates.Update3[T,T0,T1,T2,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2)
   à IronRuby.Builtins.RubySites.ModuleConstMissing(CodeContext
context, RubyModule self, String name)

The same call under ir.exe will work as expected in MRI.

Can anyone else reproduce that issue (or is it something known
already), or is my silverlight install messing up ?

cheers,

-- Thibaut
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-04-02 01:19
(Received via mailing list)
Granted, it shouldn't throw ... and doesn't for me in SL.

rb> defined?(System::Windows::Forms)
=> nil
rb> defined?(System::Windows::Forms::Controls)
=> nil
740c85b27e1a80c5f908d81dca5d4fbf?d=identicon&s=25 Jb Evain (Guest)
on 2009-04-02 01:21
(Received via mailing list)
On 4/1/09, Thibaut Barrère <thibaut.barrere@gmail.com> wrote:
>  Can anyone else reproduce that issue (or is it something known
>  already), or is my silverlight install messing up ?

Well, there's no System.Windows.Froms.Control in silverlight to begin
with.

defined?(System::Windows::Application)

does work though.
740c85b27e1a80c5f908d81dca5d4fbf?d=identicon&s=25 Jb Evain (Guest)
on 2009-04-02 01:21
(Received via mailing list)
On 4/2/09, Jb Evain <jb@nurv.fr> wrote:
>  defined?(System::Windows::Application)
>
>  does work though.

At least it works in the IronRuby repl. But trying to get a undefined
namespace doesn't throw an exception either. How're you running the
code?
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-04-02 01:31
(Received via mailing list)
System::Windows::Forms doesn't exist in Silverlight. You want
System::Windows::Controls.
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2009-04-02 01:45
(Received via mailing list)
It seems to me that this misses the most important part of the original
report:

> The same call under ir.exe will work as expected in MRI.

Presumably, System::Windows::Forms doesn't exist in MRI, either :P
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 Thibaut Barrère (thbar)
on 2009-04-02 12:33
(Received via mailing list)
Hi,

I believe I need to give you more context about what I'm doing. In Magic
(see
here<http://github.com/thbar/magic/blob/faf98c3161221e3...
in
particular) I currently have a single file providing support for WPF,
Silverlight and Windows Forms. I use defined? to determine if one of
these
are available and adopt adequate behaviour.
So that's why I run defined?(System::Windows::Forms::Control) inside
Silverlight. I can definitely think about alternatives (such as creating
a
specific file for each scenario) - I could do that but I'm trying to
stay
with a single file and avoid metaprogramming for the moment as it's much
simpler to test.

So back to the issue, now that I hope you have a clearer understanding
of
what I'm doing here.

Using ruby 1.8.6 or ironruby v0.3, running this file through command
line
[ruby/ir] my_test.rb doesn't choke:

raise "detected!" if defined?(System::Windows::Forms::Control)

Putting the same code as the first line of app.rb in a silverlight
ironruby
app fails:

MemberAccessException: uninitialized constant System::Windows::Forms

Is there any way to retrieve some accurate info on versioning from
inside
silverlight, so that I can make a better report or understand what's
happening ?

-- Thibaut
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-04-02 13:49
(Received via mailing list)
The folder SL is installed into is the version; if you're using SL2 it
should be C:\Program Files\Microsoft Silverlight\2.0.40115.0\. SL3 Beta
is C:\Program Files\Microsoft Silverlight\3.0.40307.0\.

http://jimmy.schementi.com/silverlight/repro-defined.zip

Unzip that and double-click on the index.html file. The first line of
app.xap is defined?(System::Windows::Forms), and works fine. It also
works in the console. Let me know what happens for you.

~js

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Thibaut
Barrère
Sent: Thursday, April 02, 2009 2:57 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] defined?(xxx) behaves differently when
called from Silverlight

Hi,

I believe I need to give you more context about what I'm doing. In Magic
(see
here<http://github.com/thbar/magic/blob/faf98c3161221e3...
in particular) I currently have a single file providing support for WPF,
Silverlight and Windows Forms. I use defined? to determine if one of
these are available and adopt adequate behaviour.

So that's why I run defined?(System::Windows::Forms::Control) inside
Silverlight. I can definitely think about alternatives (such as creating
a specific file for each scenario) - I could do that but I'm trying to
stay with a single file and avoid metaprogramming for the moment as it's
much simpler to test.

So back to the issue, now that I hope you have a clearer understanding
of what I'm doing here.

Using ruby 1.8.6 or ironruby v0.3, running this file through command
line [ruby/ir] my_test.rb doesn't choke:

raise "detected!" if defined?(System::Windows::Forms::Control)

Putting the same code as the first line of app.rb in a silverlight
ironruby app fails:

MemberAccessException: uninitialized constant System::Windows::Forms

Is there any way to retrieve some accurate info on versioning from
inside silverlight, so that I can make a better report or understand
what's happening ?

-- Thibaut
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 Thibaut Barrère (thbar)
on 2009-04-03 02:34
(Received via mailing list)
>
> The folder SL is installed into is the version; if you’re using SL2 it
> should be C:\Program Files\Microsoft Silverlight\2.0.40115.0\. SL3 Beta is
> C:\Program Files\Microsoft Silverlight\3.0.40307.0\.
>
I'm testing this from my Mac. I'll be searching for the files using
find.

>
>
> http://jimmy.schementi.com/silverlight/repro-defined.zip
>
>
>
> Unzip that and double-click on the index.html file. The first line of
> app.xap is defined?(System::Windows::Forms), and works fine. It also works
> in the console. Let me know what happens for you.
>

Clicking on index.html shows a welcome message and the ironruby console,
so
it doesn't seem to bang.

Editing has some weird behaviour: when I type (, defined? gets erased.
Maybe
totally unrelated, but this mean I can't test in the console.

I'm a bit puzzled as why it fails. I'll try to find some extra time to
investigate - may be related to the fact that I'm using Chiron on Mac ?

No idea what's happening for the moment.

Thanks for the repro, Jimmy.

-- Thibaut
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 Thibaut Barrère (thbar)
on 2009-04-03 02:58
(Received via mailing list)
Hey,

I finally removed all the bits of Silverlight (/Library/Internet
Plug-Ins/Silverlight* , /Library/Receipts/Silverlight*.pkg) and
reinstalled SL2.

It now works as expected. I didn't find some way to understand what
really happened, but the issue is solved anyway.

thanks for your support,

-- Thibaut
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-04-03 03:00
(Received via mailing list)
Ah, you were on a Mac. Let me know if it happens again.
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-04-03 03:02
(Received via mailing list)
From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Thibaut
Barrère
Sent: Thursday, April 02, 2009 3:44 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] defined?(xxx) behaves differently when
called from Silverlight


The folder SL is installed into is the version; if you're using SL2 it
should be C:\Program Files\Microsoft Silverlight\2.0.40115.0\. SL3 Beta
is C:\Program Files\Microsoft Silverlight\3.0.40307.0\.
I'm testing this from my Mac. I'll be searching for the files using
find.



http://jimmy.schementi.com/silverlight/repro-defined.zip



Unzip that and double-click on the index.html file. The first line of
app.xap is defined?(System::Windows::Forms), and works fine. It also
works in the console. Let me know what happens for you.

Clicking on index.html shows a welcome message and the ironruby console,
so it doesn't seem to bang.

Editing has some weird behaviour: when I type (, defined? gets erased.
Maybe totally unrelated, but this mean I can't test in the console.

I'm a bit puzzled as why it fails. I'll try to find some extra time to
investigate - may be related to the fact that I'm using Chiron on Mac ?

No idea what's happening for the moment.

Thanks for the repro, Jimmy.

-- Thibaut
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-04-03 05:03
(Received via mailing list)
Woops, hit send too soon. I just tested it out on a Mac in FF3 and
Safari3, and nothing blew up and the console rendered fine. You're
future mail said things work, so I guess I'm just confirming that your
prior installation was all-sorts-of-crazy.

Also, Chiron on the Mac wouldn't cause this, as Chiron simply serves a
XAP file, and has nothing to do with the actual running of the SL app.

~js

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Thibaut
Barrère
Sent: Thursday, April 02, 2009 3:44 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] defined?(xxx) behaves differently when
called from Silverlight


The folder SL is installed into is the version; if you're using SL2 it
should be C:\Program Files\Microsoft Silverlight\2.0.40115.0\. SL3 Beta
is C:\Program Files\Microsoft Silverlight\3.0.40307.0\.
I'm testing this from my Mac. I'll be searching for the files using
find.



http://jimmy.schementi.com/silverlight/repro-defined.zip



Unzip that and double-click on the index.html file. The first line of
app.xap is defined?(System::Windows::Forms), and works fine. It also
works in the console. Let me know what happens for you.

Clicking on index.html shows a welcome message and the ironruby console,
so it doesn't seem to bang.

Editing has some weird behaviour: when I type (, defined? gets erased.
Maybe totally unrelated, but this mean I can't test in the console.

I'm a bit puzzled as why it fails. I'll try to find some extra time to
investigate - may be related to the fact that I'm using Chiron on Mac ?

No idea what's happening for the moment.

Thanks for the repro, Jimmy.

-- Thibaut
84161f131a41bf1b730a7a4fbfd9068d?d=identicon&s=25 Vaibhav Deshpande (vaibhavdeshpandemca)
on 2009-04-03 17:25
Jb Evain wrote:
> On 4/1/09, Thibaut Barrè²¥ <thibaut.barrere@gmail.com> wrote:
>>  Can anyone else reproduce that issue (or is it something known
>>  already), or is my silverlight install messing up ?
>
> Well, there's no System.Windows.Froms.Control in silverlight to begin
> with.
>
> defined?(System::Windows::Application)
>
> does work though.
This topic is locked and can not be replied to.