Remoting

J

Jayme.Pechan

I realize this is a complicated scenerio to explain so hopefully it will
make sense. I have an object that I create an instance of on a remote
server. I can call functions on this object with no problem but one of the
things that I'd like to do is create an instance of a different object on my
local server and pass the reference to the remote server object as a
parameter which in turn would occasionally call functions on this new local
object. When I pass the interface as a parameter to a function or in this
case try to assign it to a property in the remote object, I get an error.
Note that this same code works on the same machine across app domains. The
object, of course, is derived from MarshalByRefObj but even so, it gives me
an error...

"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed."

Unfortunately I do not know what security it is referring to here. I'm not
sure if this is even a valid description for the problem. Does anyone know
enough about remoting or the related security to know what it is referring
to here? Thanks.

Here is the stack trace when the exception is thrown.

Server stack trace:
at
System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type
type)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObject(ParseRecord
pr)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord
pr)
at
System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler
handler, ISerParser serParser)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler)
at
System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream
inputStream, Header[] h, Boolean bStrictBinding, TypeFilterLevel
securityLevel)
at
System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack
sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream
requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders,
Stream& responseStream)

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 [...]set_logging(Logging value)
...

-Jayme
 
A

Alberto Poblacion

Jayme.Pechan said:
"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed."

Unfortunately I do not know what security it is referring to here. I'm
not sure if this is even a valid description for the problem. Does anyone
know enough about remoting or the related security to know what it is
referring to here? Thanks.

This would have worked in the Framework 1.0, but in later versions some
security was added to the connections so that a connection opened from the
client into the server does not by default allow the server to call an
object on the client. If you want to allow this, you have to set the
typeFilterLevel attribute of the formatter at the server and the client to
Full.

If you are using the .config file to configure your remoting, this is
accomplished by adding an attribute in the xml:

<channel ...>
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
...
</channel>

If you are using code to configure the remoted objects, it is slightly
more involved, because you have to create the provider and add it to the
channel:

BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 8085;
TcpChannel chan = new TcpChannel(props, null, provider);

Remember that you will need a similar configuration at the client and at
the server.
 
J

Jayme.Pechan

That worked. thanks!

Alberto Poblacion said:
Jayme.Pechan said:
"Because of security restrictions, the type
System.Runtime.Remoting.ObjRef cannot be accessed."

Unfortunately I do not know what security it is referring to here. I'm
not sure if this is even a valid description for the problem. Does
anyone know enough about remoting or the related security to know what it
is referring to here? Thanks.

This would have worked in the Framework 1.0, but in later versions some
security was added to the connections so that a connection opened from the
client into the server does not by default allow the server to call an
object on the client. If you want to allow this, you have to set the
typeFilterLevel attribute of the formatter at the server and the client to
Full.

If you are using the .config file to configure your remoting, this is
accomplished by adding an attribute in the xml:

<channel ...>
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
...
</channel>

If you are using code to configure the remoted objects, it is slightly
more involved, because you have to create the provider and add it to the
channel:

BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 8085;
TcpChannel chan = new TcpChannel(props, null, provider);

Remember that you will need a similar configuration at the client and at
the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top