# Problem with RubyDotNet r3 evaluator .rbw

**URL:** <https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034>\
**Category:** ruby-talk\
**Created:** [14 September 2003 00:01 UTC](https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034 "2003-09-14T00:01:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laurent\_Julliard4](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@Laurent\_Julliard4](https://rubytalk.org/u/Laurent_Julliard4)\
**Post date:** [14 September 2003 00:01 UTC](https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034/1 "2003-09-14T00:01:52Z")

</div>

I just downloaded R.D.N. r3 and I’ve got a little problem.  
If I try to run the evaluator scipt I get this error:

c:/programmi/ruby-1.8/ruby/lib/ruby/site\_ruby/1.8/dotnet/bridge.rb:124:in  
`inter nalSendMessage': It is invalid to push a main message loop in this context. This may cause your application to not respond to Windows messages. (DotNetException ) from c:/programmi/ruby-1.8/ruby/lib/ruby/site_ruby/1.8/dotnet/bridge.rb: 124:in `sendMessage’  
from  
c:/programmi/ruby-1.8/ruby/lib/ruby/site\_ruby/1.8/dotnet/bridge.rb:  
273:in `method_missing' from evaluator.rbw:165:in `runNewOnForm’  
from evaluator.rbw:248

I even get this error with this simple script:

> > require ‘dotnet’  
> > =\> true  
> > loadLibrary(‘System.Windows.Forms’)  
> > =\> #\<DotNetObject:0x27eb1a0 @dotNet=#DotNet:0x27ec4a8,  
> > @objectRef=#WrappedObjectRef:0x27eb518\>  
> > Application.run(Form.new)

…same error…

I thought this should work ☹  
BTW, I’m not much into the .net development, so possibly I’m just  
doing a wrong thing.

OTOH, running tests work fine, some tests are failing cause it seem I  
don’t have csc.exe in my path…

anyway this is really an impressive package!  
Just two things:

- would you please add the online documentation to the archive? goin  
online just to get some docs that could safely fit in the .zip file is  
a PITA.

- would you add some more samples?

---

<div class="post-metadata">

**Author:** ![Benjamin\_Schroeder](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Benjamin\_Schroeder](https://rubytalk.org/u/Benjamin_Schroeder)\
**Post date:** [14 September 2003 02:29 UTC](https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034/2 "2003-09-14T02:29:29Z")

</div>

> I even get this error with this simple script:
> 
> > > require ‘dotnet’  
> > > =\> true  
> > > loadLibrary(‘System.Windows.Forms’)  
> > > =\> #\<DotNetObject:0x27eb1a0 @dotNet=#DotNet:0x27ec4a8,  
> > > @objectRef=#WrappedObjectRef:0x27eb518\>  
> > > Application.run(Form.new)
> 
> …same error…

Do you get this error when running from irb? That seems to work for  
me. (A script file should work as well.) I’d be interested to hear  
whether it works in that context.

I think what is going on when you are in the evaluator is that an  
application loop is already running (to display the evaluator window),  
so .NET doesn’t want to run one on top of it. Does it work to do  
something like “Form.new.show” instead? When there’s already a loop  
running, like in the evaluator, that will show the window and let it  
handle events.

When running from a top-level script, the Application.run should be the  
thing to do. This would set up the “main window” for your app. Just  
calling show in that context would cause the window to disappear  
immediately afterwards.

Hope this helps - please let me know what you find out!

> OTOH, running tests work fine, some tests are failing cause it seem I  
> don’t have csc.exe in my path…

I’m glad to hear that! We aren’t in general as sure about the  
portability of the test and build environments. The tests that are  
failing because of csc are, I think, mostly just trying to use  
libraries that we set up to test particular interop features.

> anyway this is really an impressive package!  
> Just two things:
> 
> - would you please add the online documentation to the archive? goin  
> online just to get some docs that could safely fit in the .zip file is  
> a PITA.

Thanks - and, yes - that’s a good idea. We’ll add the documentation to  
the next release, R4.

> - would you add some more samples?

Sure! Is there any kind of sample you’d like to see?

Thanks,  
Ben Schroeder

> **···**
>
> On Saturday, September 13, 2003, at 08:01 PM, gabriele renzi wrote:

---

<div class="post-metadata">

**Author:** ![Benjamin\_Schroeder](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Benjamin\_Schroeder](https://rubytalk.org/u/Benjamin_Schroeder)\
**Post date:** [14 September 2003 02:41 UTC](https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034/3 "2003-09-14T02:41:52Z")

</div>

I just realized that I may have misunderstood - rereading your message,  
it looks like you are getting the error when you just even try to run  
the evaluator script at all. Sorry for the misunderstanding. Here are  
a couple of other things you could try, in that case.

First, what versions of .NET and Ruby are you running? We have tested  
against Microsoft .NET 1.1 and the latest Pragmatic Programmers Ruby  
1.8 installation download.

Second, would you try this script and see if it works?

```
require 'dotnet'
dotNet = SocketDotNet.startNew
dotNet.Application.Run(dotNet.Form.new)
dotNet.exitDotNet

```

The socket version has a different threading system than the direct  
version that’s implicitly loaded into the globals.

Thanks,  
Ben Schroeder

> **···**
>
> On Saturday, September 13, 2003, at 10:29 PM, I wrote:
> 
> > On Saturday, September 13, 2003, at 08:01 PM, gabriele renzi wrote:
> > 
> > > I even get this error with this simple script:
> > > 
> > > > > require ‘dotnet’  
> > > > > =\> true  
> > > > > loadLibrary(‘System.Windows.Forms’)  
> > > > > =\> #\<DotNetObject:0x27eb1a0 @dotNet=#DotNet:0x27ec4a8,  
> > > > > @objectRef=#WrappedObjectRef:0x27eb518\>  
> > > > > Application.run(Form.new)
> > > 
> > > …same error…
> > 
> > Do you get this error when running from irb? That seems to work for  
> > me. (A script file should work as well.) I’d be interested to hear  
> > whether it works in that context.

---

<div class="post-metadata">

**Author:** ![Laurent\_Julliard4](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@Laurent\_Julliard4](https://rubytalk.org/u/Laurent_Julliard4)\
**Post date:** [14 September 2003 18:44 UTC](https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034/4 "2003-09-14T18:44:24Z")

</div>

> Do you get this error when running from irb?

yes

> That seems to work for  
> me. (A script file should work as well.) I’d be interested to hear  
> whether it works in that context.

running from a file with ruby filename.rb fail with the same error.  
It works like a charm with Form.new.show  
Anyway, I didn’t run this script in the evaluator, cause the evaluator  
won’t start at all 🙂

> > - would you add some more samples?
> 
> Sure! Is there any kind of sample you’d like to see?

Another useful thing would be the usage of System.Data.

I think that some sample using System.Windows.Forms would cause a good  
impression on the casual downloader 😉  
In the general sense, it would be cool to have some irb-controlled  
script.  
i.e. show a simple WinForm running and calling methods of the GUI from  
irb.  
On the same line some I think something really cool would be a  
TestSuite written in ruby for .net classes, similar in spirit to  
[http://www.testing.com/writings/bypassing-the-gui.pdf](http://www.testing.com/writings/bypassing-the-gui.pdf)

I mean, ruby as a tool.

Another cool thing would be some example of System.Data.

I think these are the stuff you’re using ATM, possibly because many  
other .net packages are lready available in ruby, and some are ,  
maybe, not easily integrated with ruby (I suppos, for example, the web  
stuff.)

thanks for the quick answer, sorry if my posts come on the list latre,  
I think my provider is having some prob with the newserver

> **···**
>
> il Sun, 14 Sep 2003 11:29:29 +0900, Benjamin Schroeder [benschroeder@acm.org](mailto:benschroeder@acm.org) ha scritto::

---

<div class="post-metadata">

**Author:** ![Benjamin\_Schroeder](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Benjamin\_Schroeder](https://rubytalk.org/u/Benjamin_Schroeder)\
**Post date:** [14 September 2003 22:01 UTC](https://rubytalk.org/t/problem-with-rubydotnet-r3-evaluator-rbw/8034/5 "2003-09-14T22:01:35Z")

</div>

> > That seems to work for  
> > me. (A script file should work as well.) I’d be interested to hear  
> > whether it works in that context.
> 
> running from a file with ruby filename.rb fail with the same error.  
> It works like a charm with Form.new.show  
> Anyway, I didn’t run this script in the evaluator, cause the evaluator  
> won’t start at all 🙂

I’m glad to hear that Form.new.show works for you - it’s almost as if  
your machine always has an event loop running. Seems strange …

I’m not sure how much experience you have with .NET, but if you have a  
chance and want to try it, one idea would be to see what the  
corresponding C# program (to start a form) would do. Please contact me  
via private mail if you try it, as I’d be interested to know the  
results.

> (example ideas)

> I think these are the stuff you’re using ATM, possibly because many  
> other .net packages are lready available in ruby, and some are ,  
> maybe, not easily integrated with ruby (I suppos, for example, the web  
> stuff.)
> 
> thanks for the quick answer, sorry if my posts come on the list latre,  
> I think my provider is having some prob with the newserver

Thanks for the ideas of samples to include. We’ll work out a few of  
these for the next release. You’re correct to say that those are the  
kinds of things that we’re using - much of what .NET provides is also  
provided for Ruby in Ruby packages.

As far as web stuff - you might be interested to see John’s  
WebEvaluator sample. It’s at

```
http://www.saltypickle.com/Home/WebEvaluator

```

It’s an [ASP.NET](http://ASP.NET) application that lets you try out code using the  
Ruby/.NET bridge, including [ASP.NET](http://ASP.NET) code.

By the way, if you happen to write any interesting samples yourself,  
I’d encourage you to feel free to post them on the RubyDotNet web site

- it’s a wiki site, so anybody can edit it.

Thanks,  
Ben Schroeder

> **···**
>
> On Sunday, September 14, 2003, at 02:44 PM, gabriele renzi wrote:
