Bug 3804 - RemotingException when trying to round-trip a marshalbyrefobject
Summary: RemotingException when trying to round-trip a marshalbyrefobject
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: unspecified
Hardware: PC Linux
: Low normal
Target Milestone: Untriaged
Assignee: Lluis Sanchez
URL:
Depends on:
Blocks:
 
Reported: 2012-03-07 21:10 UTC by Csaba Halász
Modified: 2017-07-11 22:49 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
test case (1.69 KB, text/x-csharp)
2012-03-07 21:10 UTC, Csaba Halász
Details
proposed fix (807 bytes, patch)
2012-03-08 14:38 UTC, Csaba Halász
Details | Diff

Description Csaba Halász 2012-03-07 21:10:34 UTC
Created attachment 1478 [details]
test case

Assume a client and a server. Server has a singleton marshalbyref object exposed over remoting. Client requests said object, then tries to pass it back to some method. This works using ms .net, but fails using mono.

Sample output for attached test case:

windows:

C:\temp>RemotingTest.exe
main instance id: fd6dfb2f-fb3f-46ec-a67d-190b91257f00, other instance id: e31dc
6a2-9492-426d-b54e-d5cd3859be94
calling Test()...
Got: fd6dfb2f-fb3f-46ec-a67d-190b91257f00

linux:

$ mono --debug RemotingTest.exe
main instance id: db0e1bfb-1854-451f-ad27-751a3c35eb9a, other instance id: 9b9cce19-8262-46cd-8722-4cada5a065eb
calling Test()...

Unhandled Exception: System.Runtime.Remoting.RemotingException: Cannot cast from client type 'System.Runtime.Serialization.IObjectReference, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' to server type 'RemotingTest.MainClass'  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x001f0] in mono-2.10.8.1/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:247

Exception rethrown at [2]:

  at (wrapper xdomain-invoke) RemotingTest.MainClass:Test ()
  at (wrapper remoting-invoke-with-check) RemotingTest.MainClass:Test ()
  at RemotingTest.MainClass.Main (System.String[] args) [0x000a7] in MainClass.cs:29
[ERROR] FATAL UNHANDLED EXCEPTION: System.Runtime.Remoting.RemotingException: Cannot cast from client type 'System.Runtime.Serialization.IObjectReference, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' to server type 'RemotingTest.MainClass'  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x001f0] in mono-2.10.8.1/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:247

Exception rethrown at [2]:

  at (wrapper xdomain-invoke) RemotingTest.MainClass:Test ()
  at (wrapper remoting-invoke-with-check) RemotingTest.MainClass:Test ()
  at RemotingTest.MainClass.Main (System.String[] args) [0x000a7] in MainClass.cs:29
Comment 1 Csaba Halász 2012-03-08 14:38:37 UTC
Created attachment 1488 [details]
proposed fix

Apparently the transparent proxy returned by the first ObjRef.GetRealObject call is then further queried because it is detected as being an instance of IObjectReference. I don't know whether that behavior is ever needed.
Comment 2 Rodrigo Kumpera 2017-07-11 22:49:02 UTC
Moving to BCL

Note You need to log in before you can comment on or make changes to this bug.