k10n
Jim Klopfenstein's Radio Weblog

 

 

 

 

  Monday, June 03, 2002

Looking into remoting in the SSCLI


Lately I've been playing with the shared source implementation of the Microsoft .NET Framework (SSCLI). I downloaded and built it a while back, but it didn't become fun until I read Jason Whittington's article in the July MSDN Magazine. He passes on a technique for easily getting the whole runtime into the Visual Studio debugger, where you can set breakpoints and use all the usual debugging techniques.

Looking over the directories in the distribution, I noticed that several remoting classes were included. In an exercise in jumping in at the deep end, I decided to follow up my "Hello World" experiment with a little HTTP remoting sample.

I built an interface:

public interface IEcho
{
    void repeatAfterMe(string s);
}
and a server:
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
public class Echo : MarshalByRefObject, IEcho
{
    public Echo()
    {
        Console.WriteLine("Echo constructed");
    }
    public void repeatAfterMe(string s)
    {
        Console.WriteLine("Repeating... {0}",s);
    }
}
public class MyServer
{
    public static int Main(string[] args)
    {
       HttpChannel chan = new HttpChannel(1234);
       ChannelServices.RegisterChannel(chan);
       RemotingConfiguration.RegisterWellKnownServiceType(
           typeof(Echo),"myecho",WellKnownObjectMode.Singleton);
       System.Console.WriteLine("Hit  to exit...");
       System.Console.ReadLine();
       return 0;
     }
} 
and a client:
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
public class Client
{
    public static int Main(string [] args)
    {
       HttpChannel chan = new HttpChannel(998);
       ChannelServices.RegisterChannel(chan);
       Object obj = RemotingServices.Connect(
           typeof(IEcho),"http://localhost:1234/myecho");
       try
       {
           ((IEcho)obj).repeatAfterMe("Hi there");
       }
       catch (System.Exception e)
       {
           Console.WriteLine("Failed to connect to or call server");
           Console.WriteLine(e.Message);
       }
       return 0;
    }
} 
I compiled the three files from the command line like so:
csc /t:library echoif.cs
csc /r:echoif.dll /r:System.Runtime.Remoting.dll server.cs
csc /r:echoif.dll /r:System.Runtime.Remoting.dll client.cs

The server runs error-free (using clix, the SSCLI launcher), but the client fails with this error message:

!"ECall methods must be packaged into a system module,
     such as MSCOREE.DLL"
I can run the client in the normal .NET framework against the SSCLI server with no problem, as long as I use the versions built with the SSCLI. (The versions built with the release framework work fine with it, of course). Next step, to look at the IL and see if I can figure out what's going on. This is what I do for fun!

[Later... The SSCLI team at Microsoft has a fix for this problem. I'm sure it will be available soon in a future release]

4:23:49 PM    


Click here to visit the Radio UserLand website. © Copyright 2003 Jim Klopfenstein.
Last update: 3/14/2003; 11:41:44 AM.

June 2002
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
May   Jul




Subscribe to "k10n" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.