I have a class that extends the MarshalByRefObject class. I create an HTTPChannel, register a ChannelService and when reading and writing int and string properties everything works fine. My communication class looks like this (note that both classes are just an example, but my real project looks very similar):
public class MyCommunicationClass : MarshalByRefObject { public int IntegerValue {get; set;} public string StringValue {get; set;} public MyClass[] CustomValueArray {get; set;} }
My problem is the exception that occurs when I try to set 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)
The following information is displayed:
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>
Can someone explain to me what is happening and what am I doing wrong? Thanks!
EDIT: This is only a problem when I try to install an array MyClass. I can assign the MyClass property of the property to MyCommunicationClass without any problems.