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

  • Home
  • SEARCH
  • 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 9205437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:56:59+00:00 2026-06-17T23:56:59+00:00

To begin, here’s the code of a ruby file that I set in bin/debug

  • 0

To begin, here’s the code of a ruby file that I set in bin/debug folder of my SharpDevelop project:

class Run_Marshal

    def initialize(id, name)
        @list = []
        @list[0] = Employee_Info.new(id, name)

        File.open("employee_sheet.es", "wb") {|f| Marshal::dump(@list, f)}
    end


end

class Employee_Info

    attr_accessor :id
    attr_accessor :name

    def initialize(id, name)
        @id = id
        @name = name
    end

end

The code above allow to serialize the Employee_Info object(s) to a file. Let’s note that I have installed IronRuby.

Below is the C# code I’m using to execute the ruby code. It’s important that I pass arguments from C# to my new Ruby objects.

void Btn_exportClick(object sender, EventArgs e)
{
            var engine = Ruby.CreateEngine();
            engine.ExecuteFile("Ruby_Classes.rb");
            dynamic ruby = engine.Runtime.Globals;

            int id = 0;
            string name = "John Coles";

            dynamic foo = ruby.Run_Marshal.@new(id, name);
}

Finally, here’s the ruby code of another ruby project set in another different ruby environment.

@my_foo = File.open("Data/employee_sheet.es", "rb") {|f| Marshal.load(f)}
@name = @my_foo[0].name

And of course, I also made sure to have the Employee_Info class available in that other environment.

class Employee_Info

    attr_accessor :id
    attr_accessor :name

    def initialize(id, name)
        @id = id
        @name = name
    end

end

The code run perfectly from my SharpDevelop project and it output a serialized (marshal) file in the bin/debug folder. I then take that serialized file and put it in another folder of another ruby environment.

When I run the other environment, the program crash and produce this error: “ArgumentError occured. Undefined class/module System:: “

I made a few more tests and I realized that when I alter my above code to this (see line with the triple ‘*’:

class Run_Marshal

    def initialize(id, name)
        @list = []
        @list[0] = Employee_Info.new(0, "Beettlejuice") // ***

        File.open("employee_sheet.es", "wb") {|f| Marshal::dump(@list, f)}
    end


end

It now open the serialized file without any problem. So I suspect the problem is due to the argument passed from the C# code to the ruby code. I truly need to pass c# variables for more complex tasks but so far I have no idea how to make it works. I hoped you guys could explain what’s wrong. So how to pass argument variables from C# to Ruby?

Thank you!

  • 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-17T23:57:01+00:00Added an answer on June 17, 2026 at 11:57 pm

    I can’t explain how and why, but I solved the problem this way:

    class Run_Marshal
    
        def initialize(id, name)
            @list = []
            @list[0] = Employee_Info.new(id, name.to_s)
    
            File.open("employee_sheet.es", "wb") {|f| Marshal::dump(@list, f)}
        end
    end
    

    I added to_s to the passed string. Apparently Ruby didn’t recognize the argument as a string.

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

Sidebar

Related Questions

my question is that I have made multimap.Here is the partial code. if(binary_search(final.begin() ,
Ok, so here is the code that I'm trying to execute. begin transaction; SELECT
Here is the LaTeX code for my table: \begin{table}{| c || c | c
So here's a snippet of my code. void RoutingProtocolImpl::removeAllInfinity() { dv.erase(std::remove_if(dv.begin(), dv.end(), hasInfCost), dv.end());
my first question here.. :) Let's begin with the code... my page is <form
here's my stored procedure. ALTER PROCEDURE [dbo].[SearchIngredients] @Term NVARCHAR(50) AS BEGIN SET NOCOUNT ON;
Here is my code in Objective-C for iOS that I need help converting to
I don't understand this at all. Here is some Javascript code that works in
following code triggers an EIntOverflow exception. I can not debug it because that happens
I have here a program that is supposed to begin with an array of

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.