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

Thibaut Barrère thibaut.barrere at gmail.com
Thu Apr 2 05:56:40 EDT 2009


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>
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/f5c3556c/attachment.html>

More information about the Ironruby-core mailing list