R – WPF App hosting/executing Ruby code via IronRuby

dynamic-language-runtimeironrubywpf

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

Best Answer

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:

Related Topic