我有一个扩展MarshalByRefObject类的类。我创建了一个HTTPChannel,注册了ChannelService,在读取和写入int和string属性时,一切正常。我的通信类看起来像这样(请注意,这两个类只是一个示例,但我的真实项目看起来非常相似):
public class MyCommunicationClass : MarshalByRefObject
{
public int IntegerValue {get; set;}
public string StringValue {get; set;}
public MyClass[] CustomValueArray {get; set;}
}
我的问题是当我尝试设置为MyClass []属性时发生的异常。 MyClass声明为:
[Serializable]
public class MyClass
{
public string StringValue {get; set;}
}
我收到以下异常: System.Security.SecurityException:请求失败。堆栈跟踪显示:
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 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>
任何人都可以向我解释发生了什么,我做错了什么?谢谢!
编辑:当我尝试设置MyClass的数组时,这只是一个问题。我可以在MyCommunicationClass中分配一个属性MyClass Property而不会出现问题。