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)

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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 3804 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

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