[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

SerializationException with Remoting

Jason Schneekloth

9/28/2004 12:47:00 AM

OK, I'm working on making the simplest version of a remoting app that I
possibly can....basically, I'm trying to implement a Broker object to go
between a client and a server, so, I have a client and I have a server setup.
I have the server register the type IBroker with the system:

namespace Share
{
public delegate void ServerToClient(string data);
public delegate void ClientToServer(string data);

public interface IBroker
{
event ServerToClient ServerToClientEvent;
event ClientToServer ClientToServerEvent;

void SendServer(string data);
void SendClient(string data);
}
}

I implement this server side as a Broker object. No biggy. I register it,
then right after I register it in the server, I get an instance of the
IBroker object (actually a Broker object, but just being consistent):

this.broker = (IBroker)Activator.GetObject(typeof(IBroker),
"tcp://localhost:8080/TheBroker");

this.broker.ClientToServerEvent += new
ClientToServer(broker_ClientToServerEvent);

On the call to "this.broker.ClientToServer += ....." I get a
SerializationException thrown which has the following error:

"An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll

Additional information: Serialization will not deserialize delegates to
non-public methods."

I have no private delegates defined anywhere, everything is public. I've
done some searching on the web, but still can't figure this out, please help!!


Jason Schneekloth
4 Answers

Sam Santiago

9/28/2004 4:33:00 AM

0

Is your event handler, broker_ClientToServerEvent, declared as public? The
error seems to indicate it's declared as private.

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Jason Schneekloth" <JasonSchneekloth@discussions.microsoft.com> wrote in
message news:5ADCB68E-FFF1-458E-BBC8-BC18CAD473C8@microsoft.com...
> OK, I'm working on making the simplest version of a remoting app that I
> possibly can....basically, I'm trying to implement a Broker object to go
> between a client and a server, so, I have a client and I have a server
setup.
> I have the server register the type IBroker with the system:
>
> namespace Share
> {
> public delegate void ServerToClient(string data);
> public delegate void ClientToServer(string data);
>
> public interface IBroker
> {
> event ServerToClient ServerToClientEvent;
> event ClientToServer ClientToServerEvent;
>
> void SendServer(string data);
> void SendClient(string data);
> }
> }
>
> I implement this server side as a Broker object. No biggy. I register
it,
> then right after I register it in the server, I get an instance of the
> IBroker object (actually a Broker object, but just being consistent):
>
> this.broker = (IBroker)Activator.GetObject(typeof(IBroker),
> "tcp://localhost:8080/TheBroker");
>
> this.broker.ClientToServerEvent += new
> ClientToServer(broker_ClientToServerEvent);
>
> On the call to "this.broker.ClientToServer += ....." I get a
> SerializationException thrown which has the following error:
>
> "An unhandled exception of type
> 'System.Runtime.Serialization.SerializationException' occurred in
mscorlib.dll
>
> Additional information: Serialization will not deserialize delegates to
> non-public methods."
>
> I have no private delegates defined anywhere, everything is public. I've
> done some searching on the web, but still can't figure this out, please
help!!
>
>
> Jason Schneekloth


Robert Jordan

9/28/2004 9:41:00 AM

0

Jason Schneekloth wrote:
> OK, I'm working on making the simplest version of a remoting app that I
> possibly can....basically, I'm trying to implement a Broker object to go
> between a client and a server, so, I have a client and I have a server setup.
> I have the server register the type IBroker with the system:
>
> namespace Share
> {
> public delegate void ServerToClient(string data);
> public delegate void ClientToServer(string data);
>
> public interface IBroker
> {
> event ServerToClient ServerToClientEvent;
> event ClientToServer ClientToServerEvent;
>
> void SendServer(string data);
> void SendClient(string data);
> }
> }
>
> I implement this server side as a Broker object. No biggy. I register it,
> then right after I register it in the server, I get an instance of the
> IBroker object (actually a Broker object, but just being consistent):
>
> this.broker = (IBroker)Activator.GetObject(typeof(IBroker),
> "tcp://localhost:8080/TheBroker");
>
> this.broker.ClientToServerEvent += new
> ClientToServer(broker_ClientToServerEvent);
>
> On the call to "this.broker.ClientToServer += ....." I get a
> SerializationException thrown which has the following error:
>
> "An unhandled exception of type
> 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
>
> Additional information: Serialization will not deserialize delegates to
> non-public methods."
>
> I have no private delegates defined anywhere, everything is public. I've
> done some searching on the web, but still can't figure this out, please help!!

The event handler must be declared broker_ClientToServerEvent public
ciao
Rob

Jason Schneekloth

9/28/2004 6:05:00 PM

0

Ok, so that problem was solved pretty easily, makes sense now...

I have a new problem, however, a new SerializationException is being thrown:

"An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll

Additional information: Cannot find the assembly Client,
Version=1.0.1732.21050, Culture=neutral, PublicKeyToken=null."

This is being thrown by the client on the call to add a new delegate to the
event:

this.broker.ServerToClientEvent += new
ServerToClient(broker_ServerToClientEvent);

Not sure what is going on here, it's running inside of the assembly it's
looking for, only other time I've come across this can't find assembly stuff
was when I'm instantiating objects outside of the current working directory
and I have to use AppendPrivatePath, but I can't see how I can use that here
(i tried, and it didn't seem to change anything)....any help here?

Jason

Ryan Berry

9/30/2004 2:17:00 PM

0

Jason,

What you have to do is create a "shared" dll that is referenced by
both the "client" and the "server". (Again, using the terms loosely,
as either parties can be a server or a client when using 2-way remoted
events.) This shared dll would contain an interface implemented by the
"client" and referenced by the server to make calls on. What's
happening (even if they're on the same machine) is that the server is
attempting to locate the library that contains the ibroker interface,
and fails. I would put that interface into a seperate dll, and
reference it on both sides.

-- Ryan Berry