Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:18:31+00:00 2026-06-13T13:18:31+00:00

I wrote the following Ruby code file: require ‘MyAssembly.dll’ class MyClass def initialize(obj) System::Diagnostics::WriteLine(‘test’)

  • 0

I wrote the following Ruby code file:

require 'MyAssembly.dll'

class MyClass
    def initialize(obj)
        System::Diagnostics::WriteLine('test')
        @var = MyAssembly::Namespace::CSharpClass.new
    end
end

MyClass

CSharpClass is a class with one default constructor. Now, I work with this file like that:

dynamic MyClass = RubyEngine.Execute(script)
//script is a string which contains the aforementioned Ruby code as text
MyClass.@new(some_obj)

Note that MyClass has a constructor with one parameter. When I run the program, I get the following exception: ArgumentException – wrong number of arguments (0 for 1) at the last C# code line.

If I change CSharpClass to any other name there is an exception saying that I there is no such objects (so I’m guessing that assembly loading worked ok).

Now the fun part: if I change the second line in the initialize(obj) method to

@var = MyAssembly::Namespace::CSharpClass.new(nil)

then there is a long list of “test” strings in the Debug output and a StackOverflowException. So it looks like recursive MyClass object instantiating, i.e. CSharpClass.new(nil) somehow executes as MyClass.new(nil). Probably that’s why I got the AgrumentException above.

I have tried both IronRuby 1.0 and 1.1.3 but to no avail. What have I missed?

UPDATE

More fun! Now assume the Ruby code looks like this:

require 'MyAssembly.dll'

class MyClass
    def initialize(a, b)
        @var = MyAssembly::Namespace::CSharpClass.new
    end
end

MyClass.new(0, 0)

If I try to call CSharpClass.new with different arguments I get mutually exclusive exception messages:

CSharpClass.new           # wrong number of arguments (0 for 1)
CSharpClass.new(0)        # wrong number of arguments (1 for 2)
CSharpClass.new(0, 0)     # wrong number of arguments (2 for 1)
...
CSharpClass.new(<N args>) # wrong number of arguments (N for 1)

I’ll be very glad if somebody knows what I am doing wrong – I’d really like to use IronRuby in my project.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:18:31+00:00Added an answer on June 13, 2026 at 1:18 pm

    Well, that’s nice and awful at the same time. It turned out that I began my file with the following lines:

    def initialize(obj)
        MyClass.new(obj)
    end
    

    I.e. I have used the MyClass before I have declared it. Removing those lines solved the problem. It’s a wonder what kind of exceptions can dynamic code produce when something goes wrong…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Ruby code: module MyModule class MyClass def self.my_method end end
I wrote the following Ruby code: def myItems if @item1 yield @item1 end if
I wrote the following code for text file encryption and decryption. The encryption process
I am trying to decompress a file with following Ruby code. File.open(file_compressed.gz) do |compressed|
I was trying out the bcrypt-ruby gem and i wrote the following code to
i wrote following code to create a linkbutton programmatically, but its showing like lable
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
I wrote the following loop since I have to repeat the same/similar code 25
I wrote the following sample code to see how ARC works @property (nonatomic, weak)
I wrote the following code to select text from database,but when i echo the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.