How to use delegates via Romting?

  • Thread starter Thread starter Tiberiu Covaci[MCAD.NET]
  • Start date Start date
T

Tiberiu Covaci[MCAD.NET]

Hi all,

I'm trying to create 2 applications that communicate via Remoting. I'm using
..NET 2.0. If I'm declaring a method that takes a parameter of type delegate,
then the application will crash with a SecurityException, that the zone
MyComputer is not allowed to execute this piece of code. If I'm using a
MarshalByRef object, that wraps this delegate I got another kind of
exception :
System.Runtime.Serialization.SerializationException: Because of security
restrictions, the type System.Runtime.Remoting.ObjRef cannot be
accessed. ---> System.Security.SecurityException: Request
failed.System.Security.Permissions.SecurityPermission(Flags="Infrastructure")...
Does anyone have any iedas?

Best regards,
Tiberiu Covaci
 
Mark your delegate type as [Serializable].

Also, when you instantiate your delegate, target object must be
MarshalByRef, and target method must be public.

Hope it helps
 
The only thing I missed was [Serializable] for my delegate, but still does
not work.

Tibi

Francisco Garcia said:
Mark your delegate type as [Serializable].

Also, when you instantiate your delegate, target object must be
MarshalByRef, and target method must be public.

Hope it helps


Tiberiu Covaci said:
Hi all,

I'm trying to create 2 applications that communicate via Remoting. I'm
using .NET 2.0. If I'm declaring a method that takes a parameter of type
delegate, then the application will crash with a SecurityException, that
the zone MyComputer is not allowed to execute this piece of code. If I'm
using a MarshalByRef object, that wraps this delegate I got another kind
of exception :
System.Runtime.Serialization.SerializationException: Because of security
restrictions, the type System.Runtime.Remoting.ObjRef cannot be
accessed. ---> System.Security.SecurityException: Request
failed.System.Security.Permissions.SecurityPermission(Flags="Infrastructure")...
Does anyone have any iedas?

Best regards,
Tiberiu Covaci
 
When you use callbacks, the server and client change roles, that is, the
server becomes a client, and the client becomes the server. So, there must
be a callback channel so the server can call the client. Did you register a
channel for that purpose?


Tiberiu Covaci said:
The only thing I missed was [Serializable] for my delegate, but still does
not work.

Tibi

Francisco Garcia said:
Mark your delegate type as [Serializable].

Also, when you instantiate your delegate, target object must be
MarshalByRef, and target method must be public.

Hope it helps


Tiberiu Covaci said:
Hi all,

I'm trying to create 2 applications that communicate via Remoting. I'm
using .NET 2.0. If I'm declaring a method that takes a parameter of type
delegate, then the application will crash with a SecurityException, that
the zone MyComputer is not allowed to execute this piece of code. If I'm
using a MarshalByRef object, that wraps this delegate I got another kind
of exception :
System.Runtime.Serialization.SerializationException: Because of security
restrictions, the type System.Runtime.Remoting.ObjRef cannot be
accessed. ---> System.Security.SecurityException: Request
failed.System.Security.Permissions.SecurityPermission(Flags="Infrastructure")...
Does anyone have any iedas?

Best regards,
Tiberiu Covaci
 
Back
Top