Return argument has an invalid type - does remoting work reliably at all?

From: Martin Schmidt (ano_at_nym.de)
Date: 03/04/05


Date: Fri, 04 Mar 2005 01:52:22 -0800

feng wrote in 'How to debug between my calling code and remote code?' :
> I am getting error between my local code, that's making call to a
> remote object, and the called remote code. The error occoured after my
> remote object returns (I can debug to that point. And it shows the
> returned reference correctly) and before my calling code gets the
> returned reference back.
>
> The error says that the "Return argument has an invalid type". But it
> only happens in some cases, not always. Looks like it is the
> stub/skeleton throwing the error, but how do I debug this? Is there
> are a way I can debug into the stub/skeleton code? I need to know
> what's going on in there in order to fix the problem.

I am having exactly the same problem and I am running mad.

Setup:
-binary tcp channel, server resides in a console app (to be moved to a service
later)
-the shared assembly with interfaces and EventWrappers is used by client
and server
-interfaces in this assembly (simplified): IItem, IFactory
 IFactory has a method 'IItem GetItem(string ip);'.
-Implementations of IItem and IFactory are derived by MarshalByRefObject,
IFactory is
  server activated singleton through RemotingServices.Marshal, instanciated
on client
  with RemotingHelper class from Ingo Rammer (http://www.thinktecture.com)
 

Problem:
Calling GetItem raises the exception "Return argument has an invalid type".
It does so, even when I change the signature of GetItem().
Returning strings works ok, but returning e.g. just the IFactory itself or
a normal MarshalbyRef-class (defined in the shared assembly) raises again
this error:
 Return argument has an invalid type.
   System.InvalidCastException
   at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object
arg, Type paramType)
   at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
msg, Object[] outArgs, Object returnValue)
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
   at Interfaces.IFactory.GetItem(String sIPAddress)

Knowledge input:
 "Advanced .Net Remoting" by Ingo Rammer, his website, msdn, articles on
www.genuinechannels.com.

It's incredible. In my little remoting test application using interfaces
and events etc. the same way worked ok (after a long time struggling). Now
I'm starting to write production code I run into this. Any idea?

Probable solution: get rid of remoting
.Net Remoting is really a pain to work with. Working configurations are extremely
fragile. I just need reasonable interprocess communication, no web or IIS
involved. Just two processes, one constantly running in background collecting
data and the other one is a seperatly started GUI. COM is reliable and working
and I probably will have to use COM interop to communicate between my two
.Net processes. Isn't this mad?

.Net is really great, but I start to understand, why there is still no .Net
integration (compare with COM) even with the Microsoft apps like Office or
VS. Remoting just sucks. Its serialization is the only good thing about it.
Does anyone really use .Net Remoting happily in a real world application
(just on the same host is ok) without web or IIS?

Any hints are greatly appreciated.
Martin.



Relevant Pages

  • RE: Assembly reported as built without debug info - that is not true
    ... enabled or without debug information:..." ... successfully remote debug any other assembly which is not in the GAC? ... in the Modules window's loading assemblies' list, ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework)
  • RE: dll problem on Remoting app
    ... Steven Cheng ... Microsoft Online Support ... | object, the remote object is not actually created or referenced, in other ... The communiation to the remoting server won't happen until ...
    (microsoft.public.dotnet.framework)
  • Remote debugging broken on WinXP Pro SP2
    ... I've run across an unusual remote debugging problem... ... I've got 2 virtual machines running under VMware Workstation v5.5, one is WinXP Pro SP2 and the other is Win2K3 SP1. ... I can perform remote debugging w/o any problems. ... With the WinXP Pro SP2 VM, I cannot get the Visual C/C++ IDE to connect to the remote debug agent. ...
    (microsoft.public.vc.debugger)
  • Re: Remoting Problem
    ... I tried a very simple remoting solution in which I am just throwing an ... exception from the remote object for example: ... But my another Windows service, which is unfortunately in production is ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: .NET Remoting
    ... In the case of remoting, the Trx boundary is the physical machine. ... "client" machine starts a trx, ... > remote machine compared to the "client" in terms of design. ...
    (microsoft.public.dotnet.framework.remoting)