Groups | Blog | Home
all groups > dotnet remoting > september 2005 >

dotnet remoting : How to pass a MarshalByRef object as a parameter in a remote metho


Romain
9/15/2005 11:44:05 AM
Hi,

I want to write a method of a remote object that expects another type of
MarshalByRef object as a parameter. When I run it, I get a SecurityException,
but I don't undestand why.

Let's say the AvSession object is registered as a client-activated object.
It has the following method: AvSession.UpdateSupporter(AvSupporter avs),
where AvSupporter is a MarshalByRef class.

On the client-side, I am doing approximately this:

....
AvSession session = new AvSession();
....
AvSupporter sup = AvSession.Profile; // this is a public get property, works
fine
sup.Profile.Name = "test"; // This calls the set property on a field of the
Profile property, works fine too

// Update changes:
session.UpdateSupporter(sup); // This will fail before even arriving to the
server: SecurityException.

Any help would be appreciated. I think something goes wrong in my
conception, but I would like to know what.

Robert Jordan
9/15/2005 8:53:30 PM
Hi Romain,

[quoted text, click to view]

Please post the whole stacktrace.

Romain
9/17/2005 2:13:02 AM
Hi Robert,

Here is the whole StackTrace...
Sorry for the awful presentation, it was copy-pasted from a console
application :-)

Hope it will help...

Exception: System.Runtime.Serialization.SerializationException: Because of
secur
ity restrictions, the type System.Runtime.Remoting.ObjRef cannot be
accessed. --
-> System.Security.SecurityException: Request failed.
at
System.Runtime.Serialization.FormatterServices.nativeGetSafeUninitializedO
bject(RuntimeType type)
at
System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(
Type type)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.SecurityPermission
The first permission that failed was:
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Infrastructure"/>

The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Infrastructure"/>
</PermissionSet>

The only permitted permissions were:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="SerializationFormatter"/>
</PermissionSet>

The method that caused the failure was:
System.Runtime.Remoting.Channels.ServerProcessing
ProcessMessage(System.Runtime.
Remoting.Channels.IServerChannelSinkStack,
System.Runtime.Remoting.Messaging.IMe
ssage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream,
Sys
tem.Runtime.Remoting.Messaging.IMessage ByRef,
System.Runtime.Remoting.Channels.
ITransportHeaders ByRef, System.IO.Stream ByRef)
--- End of inner exception stack trace ---

Server stack trace:
at
System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(
Type type)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObject(Pars
eRecord pr)
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecor
d 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(Head
erHandler handler, ISerParser serParser)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Str
eam serializationStream, HeaderHandler handler)
at
System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage
(Stream inputStream, Header[] h, Boolean bStrictBinding, TypeFilterLevel
securit
yLevel)
at
System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IS
erverChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders
requestH
eaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders&
response
Headers, Stream& responseStream)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgDa
ta, Int32 type)
at SupporTech.Avocases.Common.IAvocasesSession.CreateSupporter(String
name, S
tring email, String login, String phone, String msnAccount,
AvocasesPermissions
avPermissions)
at SupporTech.Avocases.Client.ConsoleClient.Main(String[] args) in
S:\support
ech\avocases\v2\ConsoleClient\ConsoleClient.cs:line 56: Because of security
rest
rictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
Exception: System.Security.SecurityException: Request failed.
at
System.Runtime.Serialization.FormatterServices.nativeGetSafeUninitializedO
bject(RuntimeType type)
at
System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(
Type type)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.SecurityPermission
The first permission that failed was:
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Infrastructure"/>

The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Infrastructure"/>
</PermissionSet>

The only permitted permissions were:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="SerializationFormatter"/>
</PermissionSet>

The method that caused the failure was:
System.Runtime.Remoting.Channels.ServerProcessing
ProcessMessage(System.Runtime.
Remoting.Channels.IServerChannelSinkStack,
System.Runtime.Remoting.Messaging.IMe
ssage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream,
Sys
tem.Runtime.Remoting.Messaging.IMessage ByRef,
System.Runtime.Remoting.Channels.
ITransportHeaders ByRef, System.IO.Stream ByRef): Request failed.
AddThis Social Bookmark Button