Reputation: 99
How to call a C# dll in ruby?
Upvotes: 6
Views: 4319
Reputation: 51
You can use unmanaged exports (https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports) to create an unmanaged entry in c#. For example you can created an init_youmodulename, which is required for a ruby extension. Then you can use require 'youmodulename' to load it in ruby.
This link (https://bitbucket.org/icehuli/sucsexttutorial) has several examples. Although it aims in ruby extensions for Sketchup, it may still be interesting for you to learn how it works.
Upvotes: 2
Reputation: 15457
You can also write a native -> C# wrapper DLL using managed C++
Export all the functions you want as C calls in the DLL, e.g.
extern "C" __declspec ( dllexport ) void CallManagedMethod() {
Something^ myManagedObject ...
}
Then use FFI to call that DLL from Ruby https://github.com/ffi/ffi
Upvotes: 2
Reputation: 52316
I can think of a few possibilities:
WIN32OLE
library to call it;There's a thread on the topic here. Note that the last post is actually from John Lam (looks like March 2009) where he seems comfortable asserting that RubyCLR is still functional...
Upvotes: 4