compiler construction - Can I compile IronRuby project in VS2010 into DLL/exe file? -
after created ironruby project in vs2010 using ironruby v1.1.x, able use .net library importing them. can't compile ironruby exe/dll. see build option can't build exe or dll ironruby project. please !
you can't compile ironruby classes .net assembly , access them assembly.
preet right nearest can embed ironruby scripts in (say) c# assembly. c# side possible instantiate ruby classes. given following ruby class:
class helloworld def say_hello puts 'hello' end end
you load resource file , run c#:
using microsoft.scripting.hosting; using microsoft.scripting.runtime; using ironruby; var runtime = ironruby.ruby.createruntime(); var engine = runtime.getengine("ruby"); var assembly = assembly.getexecutingassembly(); var stream = assembly.getmanifestresourcestream("pathtoresource.test.rb"); string code = new streamreader(stream).readtoend(); var scope = engine.createscope(); engine.execute(code, scope); dynamic helloworldclass = engine.runtime.globals.getvariable("helloworld"); dynamic ironrubyobject = engine.operations.createinstance(helloworldclass); ironrubyobject.say_hello();
Comments
Post a Comment