Bug 6606 - RemotingException when using a cross domain marshaller object
Summary: RemotingException when using a cross domain marshaller object
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: Bugzilla
Depends on:
Reported: 2012-08-20 03:43 UTC by Timotheus Pokorra
Modified: 2017-07-12 23:57 UTC (History)
4 users (show)

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

patch to make cross domain marshalling work on Mono (3.57 KB, application/octet-stream)
2012-08-20 03:43 UTC, Timotheus Pokorra

Description Timotheus Pokorra 2012-08-20 03:43:59 UTC
Created attachment 2376 [details]
patch to make cross domain marshalling work on Mono

I was trying to make the CrossDomainMarshaller example work which is available here: http://www.codeproject.com/KB/IP/CrossDomainRemoting.aspx

The goal is to have several appdomains, but the server is only listening to one IP port and distributes the messages from the clients to each appdomain and service.

It works fine on MS.net.

Unfortunately, using even the latest Mono 2.11.3, you get this exception:

System.Runtime.Remoting.RemotingException: Cannot cast from client type 'ContextBoundRemoting.IPrintService, Touchcom.Prototypes.ContextBoundRemoting.Shared, Version=, Culture=neutral, PublicKeyToken=null' to server type 'ContextBoundRemoting.CrossDomainMarshaller'

Server stack trace: 
  at System.Runtime.Remoting.Messaging.MethodCall.ResolveMethod () [0x00000] in <filename unknown>:0 
  at System.Runtime.Remoting.Messaging.MethodCall..ctor (System.Runtime.Remoting.Messaging.Header[] h1) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.MessageFormatter.ReadMethodCall (BinaryElement elem, System.IO.BinaryReader reader, Boolean hasHeaders, System.Runtime.Remoting.Messaging.HeaderHandler headerHandler, System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in <filename unknown>:0 
  at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage (IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, System.IO.Stream& responseStream) [0x00000] in <filename unknown>:0 

Exception rethrown at [0]: 

  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x00000] in <filename unknown>:0 

I was able to get it to work for Mono with the attached patch. I don't know enough about .net remoting, so I guess it is not the cleanest solution. But perhaps it helps others as well...
Comment 1 Miguel de Icaza [MSFT] 2012-09-02 12:49:10 UTC
The patch contains this code:

+                               // Special behaviour for OpenPetra: need this for cross domain marshalling
+                               if ((requestType == null) && type.FullName.EndsWith("CrossDomainMarshaller")) {
+                                       requestType = Type.GetType(_typeName);
+                                       _methodBase = RemotingServices.GetMethodBaseFromName (requestType, _methodName, _methodSignature);
+                                       return;
+                               }
I do not think we should get this patch as-is.

CCing Lluis.
Comment 2 Rodrigo Kumpera 2017-07-12 23:57:52 UTC
This looks like a BCL issue.

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