[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: RubyDotNet r4 and namespaces

John R. Pierce

9/27/2003 12:47:00 PM

> > On Sat, 27 Sep 2003 10:44:00 +0900, James Britt wrote:
> If I run Learninga.rb, I get a WIndows message box, titled Microsof
> Visual C++ Runtime Library, with the message
>
> Runtime Error!
>
> Program c:\ruby\bin\ruby.exe
>
> R6029
> -This program cannot run using the active version of the Microsoft
> .NET runtime
> Please contact that application's support team for more information.
>
> I'm thinking I have path or registry issues here, and may try to remove
> earlier installations and simply use 1.1. (I've had annoying
> experiences getting the framework installed, so I'm not convinced paths
> and registry entries are entirely correct.)

Ok -- I'd double check to see if you have a ruby.exe.config (or
rubyw.exe.config) file in the ruby\bin folder. If you do, then it may be
telling .NET to favor the 1.0 framework rather than the 1.1 framework (which is
needed for the pre-built Ruby/.NET Bridge). Delete the configs if you have them
or add .NET 1.1 as a supported runtime.

If that isn't the case then I'd wonder if you can run any .NET 1.1 apps or if
your 1.1 framework is busted.

> Here's the class:
>
> using System;
> using Neurogami;
> using BlogtariDotNet;
>
> namespace Neurogami {
> class Utils{
> public static void db( string msg ) {
> Console.WriteLine( "[DBUG] " + msg );
> }
> }
> }
> // namespace BlogtariDotNet {
> class BlogtariSample {
> static void Main( string[] args ) {
> try {
> DateTime today = DateTime.Now;

> Console.WriteLine( "The time is " + today.ToString() ) ;
> BlogtariSample bs = new BlogtariSample();
> Utils.db( bs.parse( "Foobar" ) );
> }
> catch ( Exception exception ) {
> Console.WriteLine( exception.Message );
> }
> }
> public string parse( string s ) {
> return s + " <!-- Length: " + s.Length + " -->";
> }
> }
> // }

WOW, so the bugs live where the tests aren't. So, the .NET bridge will only load
namespaces that have at least one public class. The example above could be
fixed by making class BlogtariSample public (same for Utils). Interestingly
enough, the bridge doesn't need the class to be public to access it (because we
just don't honor access modifiers at all), but for some reason you need to have
at least 1 public class in the namespace. We'll investigate and most likely fix
in next release.

Regards,

John

1 Answer

James Britt

9/27/2003 2:30:00 PM

0

John R. Pierce wrote:
> Ok -- I''d double check to see if you have a ruby.exe.config (or
> rubyw.exe.config) file in the ruby\bin folder.

No such thing.

> If that isn''t the case then I''d wonder if you can run any .NET 1.1 apps or if
> your 1.1 framework is busted.

I pretty sure I could, but I''ve now since removed old .NETs, reinstalled
the most recent framework, and all seems good. The RubyDotNet samples
run fine now.

>
>
>>Here''s the class:
>>

<snip/>

>

I made the class in quesion public, uncommented the namespace and the
Ruby code workes fine, both with or without using the namespace prefix.

Making the classes I want to expose public makes sense, so having to
explcitly specify that is fine with me. In fact, I''m curious why you
would want, by default, to ignore access modifiers (though I can see it
could be handy). (Bear in mind I''ve yet to spend any length of time
delvinging into C# or the CLR.)

Thanks again for your time and trouble,

James Britt