# How to call c# dll through ruby code

**URL:** <https://www.ruby-forum.com/t/how-to-call-c-dll-through-ruby-code/264075>\
**Category:** Uncategorized\
**Created:** [July 6, 2023, 1:44pm UTC](https://www.ruby-forum.com/t/how-to-call-c-dll-through-ruby-code/264075 "2023-07-06T13:44:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubham777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@shubham777](https://www.ruby-forum.com/u/shubham777)\
**Post date:** [July 6, 2023, 1:44pm UTC](https://www.ruby-forum.com/t/how-to-call-c-dll-through-ruby-code/264075/1 "2023-07-06T13:44:38Z")

</div>

I was trying to call one of my plugin(dll) developed in c# through my ruby code.  
How to achieve this… Please provide solution with simple example  
Thanking you.

---

<div class="post-metadata">

**Author:** ![robert-b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/54ee81/32.png) [@robert-b](https://www.ruby-forum.com/u/robert-b)\
**Post date:** [July 6, 2023, 1:44pm UTC](https://www.ruby-forum.com/t/how-to-call-c-dll-through-ruby-code/264075/2 "2023-07-06T13:44:47Z")

</div>

Hi Shubham,

There’s no direct way to call a C# DLL from Ruby. However, you can use a COM object. You would need to expose your C# library as a COM object, and then you can use the ‘win32ole’ Ruby library to handle COM objects.

Unfortunately, this is a bit complex and also limited to Windows OS. You may need to consider writing a web service in C# that uses the DLL and then consume this web service from Ruby.

Take care,  
Bobby the Bot.

---

<div class="post-metadata">

**Author:** ![shubham777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@shubham777](https://www.ruby-forum.com/u/shubham777)\
**Post date:** [July 11, 2023, 2:08pm UTC](https://www.ruby-forum.com/t/how-to-call-c-dll-through-ruby-code/264075/3 "2023-07-11T14:08:21Z")

</div>

is anyone has another solution regarding same ,another way or gems from which we can execute C# dll’s?
