[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 3:49:00 AM

On Sat, 27 Sep 2003 10:44:00 +0900, James Britt wrote:

> I grabbed the r4 release of RubyDotNet from
> http://www.saltypickle.com/..., and it works great (well, on my
> laptop. My main PC seems to have issues with multiple versions of the
> .net framework installed).

Very interesting....both of us (the developers) are running our machines with
both version of .NET (1.0 and 1.1) as we develop this product. Can you provide
us specific errors you are getting?

> I had no trouble writing my own C# class and calling it from Ruby
> (pretty sweet). But I if put my class in a namespace I can't get the
> Ruby code to find it. I get errors about an unknown constant (i.e., the
> namespace for the C# class).

Are you building your custom C# class under .NET 1.1? Are you referencing the
dll using a fully qualified path including extension? If so to both of these,
can you provide a copy of your class either on this mailing list or directly to
me (if it is too big). I'd like to see this.

We actually have this exact scenario in a test case included in the
distribution. If you look in the Ruby\tests folder you will find a test file
called "TestCoreBridge.rb". Inside this file there are several test cases with
respect to the class "TestClasses.NumberHolder". I'd be curious if this test
passes on your machine. To run the tests you must be in a command prompt that
has csc.exe in the path as the test will compile a custom c# class and then
access it.

> On a side note, is there a connection between RubyDotNet at
> saltypickle.com, and the rubydotnet at rubydotnet.sourceforge.net, other
> the (confusing) use of essentially the same name?

Gosh, what were we thinking? Guess we need a namespace to resolve conflicts.
Anyways, www.saltypickle.com is the home the Ruby/.NET bridge. We also run a
site on rubyforge.org called rubydotnet. SourceForge already had a rubydotnet
project -- and we didn't know it until too late. Guess this explanation is still
confusing -- oh well.

Regards,

John

1 Answer

James Britt

9/27/2003 5:38:00 AM

0

John R. Pierce wrote:

> On Sat, 27 Sep 2003 10:44:00 +0900, James Britt wrote:
>
>
>>I grabbed the r4 release of RubyDotNet from
>>http://www.saltypickle.com/..., and it works great (well, on my
>>laptop. My main PC seems to have issues with multiple versions of the
>>.net framework installed).
>
>
> Very interesting....both of us (the developers) are running our machines with
> both version of .NET (1.0 and 1.1) as we develop this product. Can you provide
> us specific errors you are getting?

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.)

>
>
>>I had no trouble writing my own C# class and calling it from Ruby
>>(pretty sweet). But I if put my class in a namespace I can''t get the
>>Ruby code to find it. I get errors about an unknown constant (i.e., the
>> namespace for the C# class).
>
>
> Are you building your custom C# class under .NET 1.1? Are you referencing the
> dll using a fully qualified path including extension? If so to both of these,
> can you provide a copy of your class either on this mailing list or directly to
> me (if it is too big). I''d like to see this.

Yes to both. csc.exe tells me:
C:\>csc
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

(Curiously, I see now that I have assorted earlier version on the laptop
as well. Not sure that matters, or they''re of any value.)

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 + " -->";
}
}
// }

Anyway, so long as the BlogtariDotNet namespace is left commented, and
my Ruby code just calls BlogtariSample.new() directly, all is good.
But trying to use the name space and calling
BlogtariDotNet.BlogtariSample.new() fails.


Thanks, and thanks for the outstanding code.


James Britt