# Problem setting .NET member variables

**URL:** <https://www.ruby-forum.com/t/problem-setting-net-member-variables/184254>\
**Category:** IronRuby\
**Created:** [February 27, 2010, 8:02am UTC](https://www.ruby-forum.com/t/problem-setting-net-member-variables/184254 "2010-02-27T08:02:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rawroe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@rawroe](https://www.ruby-forum.com/u/rawroe)\
**Post date:** [February 27, 2010, 8:02am UTC](https://www.ruby-forum.com/t/problem-setting-net-member-variables/184254/1 "2010-02-27T08:02:11Z")

</div>

Hello, can anyone help me with this issue? I have the following code  
running in C#:

ScriptRuntime runtime = Ruby.CreateRuntime();  
ScriptEngine engine = Ruby.GetEngine(runtime);  
ScriptScope scope = runtime.CreateScope();  
scope.SetVariable(“model”, model);  
StreamReader sr = new  
StreamReader(ConfigurationManager.AppSettings[“RubyFlagsPath”] +  
flagName + “.rb”);  
string rubyScript = sr.ReadToEnd();  
engine.Execute(rubyScript, scope);

which runs this Ruby code in part:

model.Transaction.Runs[0].RunLoan.RunBorrowers[2].RunLoan.RunFlagTestResults[0].Passed  
= false  
model.Transaction.Runs[0].RunLoan.RunBorrowers[3].RunLoan.RunFlagTestResults[0].Passed  
= true

f.syswrite(“passed3  
#{model.Transaction.Runs[0].RunLoan.RunBorrowers[2].RunLoan.RunFlagTestResults[0].Passed}  
\n”)  
f.syswrite(“passed4  
#{model.Transaction.Runs[0].RunLoan.RunBorrowers[3].RunLoan.RunFlagTestResults[0].Passed}  
\n”)

The output I get is the following:

true  
true

Obviously something is not quite right, the results should have been  
false, true. Now, I’ve tried this with up to four borrowers and each  
time the consistent pattern I’m seeing is that whatever I set the last  
passed status to is set for ALL the borrowers. Somehow Ruby is setting  
the passed status for all borrowers at once with each call, even though  
they are in completely different objects.

---

<div class="post-metadata">

**Author:** ![rawroe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@rawroe](https://www.ruby-forum.com/u/rawroe)\
**Post date:** [March 1, 2010, 5:19pm UTC](https://www.ruby-forum.com/t/problem-setting-net-member-variables/184254/2 "2010-03-01T17:19:20Z")

</div>

I believe this was an internal object reference issue - in .NET, not in  
Ruby. thanks!
