0

Hey folks, hoping you can help me get started with IronRuby. I have several Ruby scripts that I want to execute from my WPF Application (due to the use of several RMagick methods I can't get natively) and I can't find any good info on what references I need in the project.

I've installed IronRuby and tried adding Microsoft.Scripting and .Core but the app complains that I have no Sub Main method - can IronRuby be used in a non-console app?

Thanks, Becky

Becky Green
  • 625
  • 5
  • 21

1 Answers1

2

Of course it can be used in a non-console app! that's what it all about :)

You need to add references to IronRuby.dll, IronRuby.Libraries.dll, Microsoft.Scripting.dll and Microsoft.Scripting.Core.dll.

Then you have multiple ways to execute IronRuby code or files like IronRuby.GetEngine().Execute("puts 'hello world'") or IronRuby.GetEngine().ExecuteFile("iron_ruby_file.rb").

Look at the next resources for more info about how to execute IronRuby code from C# code:

Shay Friedman
  • 4,808
  • 5
  • 35
  • 51
  • Thank you so much for those links! The first one especially was useful. I'm having an issue with those 4 references as I receive this error: Unknown build error, 'Cannot resolve dependency to assembly 'Microsoft.Scripting.ExtensionAttribute, Version=0.9.5.1, Culture=neutral, PublicKeyToken=null' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' I can't work out how to resolve this error so I can use IronRuby in my WPF project. – Becky Green Dec 04 '09 at 09:40
  • Seems like you need to add a reference to Microsoft.Scripting.ExtensionAttribute.dll as well. – Shay Friedman Dec 04 '09 at 12:34
  • That's what I tried, then the build fails due to several: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'. I'm sure this is something daft I'm doing but I haven't figured out what! – Becky Green Dec 04 '09 at 12:51
  • I've submitted as a bug as I get a failed build but no error when adding the five references to a brand new WPF Application. :o) – Becky Green Dec 04 '09 at 15:55
  • To be clear, this issue is only with VB.NET WPF projects; C# WPF projects work as expected. The problem is the VB.NET compiler doesn't treat the ExtensionAttribute DLL the same way as C#. – Jimmy Schementi Dec 29 '09 at 18:57