C# Remoting (MarshalByRefObject) problem with System.Security.PermissionSet
I have a class that extends MarshalByRefObject class. I create a HTTPChannel, register the ChannelService and while reading and writing the int and string properties everything works fine. My communication class looks like this (please note that both classes are only an example, but my real project looks really similar):
public class MyCommunicationClass : MarshalByRefObject
{
public int IntegerValue {get; set;}
public string StringValue {get; set;}
public MyClass[] CustomValueArray {get; set;}
}
My problem is an exception that occures when I try to set to the MyClass[] property. MyClass is declared as:
[Serializable]
public class MyClass
{
public string StringValue {get; set;}
}
I get the following exception: System.Security.SecurityException: Request failed. The stack trace shows:
The method that caused the failure
was:
System.Runtime.Remoting.Channels.ServerProcessing
ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack,
System.Runtime.Remoting.Messaging.IMessage,
System.Runtime.Remoting.Channels.ITransportHeaders,
System.IO.Stream,
System.Runtime.Remoting.Messaging.IMessage
ByRef,
System.Runtime.Remoting.Channels.ITransportHeaders
ByRef, System.IO.Stream ByRef)
Aditional information shown:
The action that failed was: Demand The
type of the first permission that
failed was:
System.Security.PermissionSet The
demand was for: <PermissionSet
class="System.Security.PermissionSet"
version="1" Unrestricted="true"/>
The only permitted permissions were:
<PermissionSet
class="System.Security.PermissionSet"
version="1"> <IPermission
class="System.Security.Permissions.SecurityPermission,
mscorlib, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="SerializationFormatter"/>
</PermissionSet>
开发者_StackOverflow社区
Can anyone explain to me what is going on and what am I doing wrong? Thank you!
EDIT: This is only a problem when I try to set an array of MyClass. I can assign a property MyClass Property in the MyCommunicationClass without a problem.
精彩评论