tags:

views:

287

answers:

1

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

+2  A: 

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
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 Franklin
Seems like you need to add a reference to Microsoft.Scripting.ExtensionAttribute.dll as well.
Shay Friedman
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 Franklin
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 Franklin
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