[Ironruby-core] defined?(xxx) behaves differently when called from Silverlight

Jimmy Schementi Jimmy.Schementi at microsoft.com
Thu Apr 2 06:43:25 EDT 2009

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\.


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.


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


I believe I need to give you more context about what I'm doing. In Magic (see here<http://github.com/thbar/magic/blob/faf98c3161221e309290e7a6e311adb27fddf825/lib/magic.rb#L32> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090402/ab7ad2d6/attachment.html>

More information about the Ironruby-core mailing list