return from server only works for built-in types
- From: Jakob E. Madsen <JakobEMadsen@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Aug 2007 13:44:02 -0700
The _r.Execute Method always works, no problem (see below).
But when I call _r.GetStatistics() the client fails with the exception shown
below.
It all works if I run the client and the server on the same network, but the
GetStatistics fails when client and server is on different networks. I am
calling the server this way from the client
ro.ri _r =
(ro.ri)Activator.GetObject(typeof(ro.ri),"http://www.webserver.com:1236/s");
And
string str = _r.Execute("test command"); // <-- Works
ro.Statistics stats = _r.GetStatistics(); // <-- Fails
It seems like it fails when my custom object is returned, but not when int
or string
is returned from the server. As if two-way only works for built-in types. I
GetStatistics() call actually makes it to the server and the server does not
receive any errors.
Any help much appreciated.
Thanks & have a great day,
Jakob
===
My interface for the remoting object
using System;
using System.Collections.Generic;
using System.Text;
namespace ro
{
public interface Statistics
{
int CallsServedCtr {get;}
string TheStory {get;}
}
public interface ri
{
string Execute(string Command);
Statistics GetStatistics();
}
}
It is implemented this way on the server side
using System;
using System.Collections.Generic;
using System.Text;
namespace s
{
[Serializable]
class rii : MarshalByRefObject, ro.ri
{
protected Server _server = null;
public override object InitializeLifetimeService()
{
return null;
}
public rii()
{
_server = s.Server.TheForm;
}
public string Execute(string Command)
{
_server.CallsServed++;
return Command + " was executed, all went just fine";
}
public ro.Statistics GetStatistics()
{
_server.CallsServed++;
StatisticsImplmentation stats = new
StatisticsImplmentation(_server);
return stats;
}
}
[Serializable]
class StatisticsImplmentation : MarshalByRefObject, ro.Statistics
{
public StatisticsImplmentation(Server server)
{
_callsServedCtr = server.CallsServed;
_theStory = "Ok, here's story as of " +
DateTime.Now.ToLongTimeString();
}
private int _callsServedCtr;
public int CallsServedCtr
{
get { return _callsServedCtr; }
set { _callsServedCtr = value; }
}
private string _theStory;
public string TheStory
{
get { return _theStory; }
set { _theStory = value; }
}
}
}
Exception on client.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
Server stack trace:
at System.Net.HttpWebRequest.GetRequestStream()
at
System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
at
System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage
msg, ITransportHeaders requestHeaders, Stream requestStream,
ITransportHeaders& responseHeaders, Stream& responseStream)
at
System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at ro.Statistics.get_TheStory()
at c.Client.GetStatistics_Click(Object sender, EventArgs e) in
C:\Remoting1\c\Client.cs:line 87
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
c
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Data/Remoting1/c/bin/Debug/c.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
ro
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Data/Remoting1/c/bin/Debug/ro.DLL
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Runtime.Serialization.Formatters.Soap
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Serialization.Formatters.Soap/2.0.0.0__b03f5f7f11d50a3a/System.Runtime.Serialization.Formatters.Soap.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
.
- Follow-Ups:
- Re: return from server only works for built-in types
- From: Joel Lyons
- Re: return from server only works for built-in types
- Prev by Date: CPU at 50%
- Next by Date: Slow Remoting
- Previous by thread: CPU at 50%
- Next by thread: Re: return from server only works for built-in types
- Index(es):