[Mono-list] Remoting betweem Mono and MS .NET
Yuri Leikind
y.leikind@sam-solutions.net
Mon, 21 Jun 2004 18:24:21 +0300
On Mon, 21 Jun 2004 16:35:39 +0200
"RoBiK" <robik@mailbox.sk> wrote:
> I use remoting between Mono and MS.NET, and it works fine for me. What
> problems do you have?
>
> Robert
I run a remoting server on Linux, and try to use it from the Windows machine.
Here is my code:
common interface, build as a separate assembly
==================
namespace ProofOfConcepts{
public interface ITest{
string SayHello();
}
}
================== Client
using System;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
namespace ProofOfConcepts{
class Client{
ITest ar;
public Client(string host, int port, string endPoint){
HttpChannel channel = new HttpChannel(0);
ChannelServices.RegisterChannel(channel);
MarshalByRefObject obj =
(MarshalByRefObject) RemotingServices.Connect(
typeof(ProofOfConcepts.ITest),
"http://" + host + ":" + port + "/" + endPoint);
ar = (ITest) obj;
}
public string SayHello(){
return ar.SayHello();
}
public static void Main(string[] args){
Client client = new Client(args[0], 60000, "MyEndPoint");
Console.WriteLine(client.SayHello());
}
}
}
================== Server
using System;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
namespace ProofOfConcepts{
public class AssemblyCache : MarshalByRefObject, ITest{
public string SayHello(){
return "hello";
}
}
class RemotingServer{
public RemotingServer(object obj){
HttpChannel channel = new HttpChannel(60000);
ChannelServices.RegisterChannel(channel);
MarshalByRefObject mobj = (MarshalByRefObject) obj;
RemotingServices.Marshal(mobj, "MyEndPoint");
}
void Listen(){
Console.WriteLine("Press Enter to exit...");
Console.ReadLine( );
}
public static void Main(){
AssemblyCache ar = new AssemblyCache();
RemotingServer rServer = new RemotingServer(ar);
rServer.Listen();
}
}
}
==================
Here is what I get running the client:
Unhandled Exception: System.Net.WebException: The underlying connectio
n was closed: The request was canceled.
Server stack trace:
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult async
Result)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.Pr
ocessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStre
am)
at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.Pr
ocessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream re
questStream, ITransportHeaders& responseHeaders, Stream& responseStrea
m)
at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncPro
cessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IM
essage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageD
ata& msgData, Int32 type)
at ProofOfConcepts.ITest.SayHello()
at ProofOfConcepts.Client.Main(String[] args)
=======================
My Mono version is 0.95, MS .NET version 1.1.4322
--
Best regards,
Yuri Leikind