.net - Serialization exception in remoting C# -
i've been trying lot before writing question couldn't find answer problem.
i'm making remoting program, it's store, i've implemented .dll, server , client, , ok except fact have big problem related serialization, little summary code.
[serializable] public class almacen { int nusuarios_on, nusuarios_reg; bool server_on; arraylist clientes_activos; arraylist clientes_registrados; arraylist productos_almacen;} [serializable] public class cliente { protected int id; protected string usuario, dni; private string contraseña; pedido pedido;} [serializable] public class pedido { arraylist productos; bool confirmado; int preciototal;} [serializable] public class producto { private string nombre; private int codigo, precio, unidades, stock; //stock solo lo usamos en el almacen, y unidades solo en pedido.}
then, have .dll service, in have method 'pedido' object passed value in parameter, when method called.
public class servicioalmacen : marshalbyrefobject { private almacen almacen; . . . public int añadirproductoalmacen(int id, producto p) { if(id==1) { if(!productorepetido(p)) { almacen.getproductos_almacen().add(p); console.writeline("añadido el producto {0} al almacen.", p.getcodigo()); return 0; } else { console.writeline("intento de añadir un producto repetido."); return -1; } } else { console.writeline("acceso denegado."); return -2; } } . . . }
when method called in client side, serializationexception tells me servicealmacen.producto not tagged serialized. dont understand why exception because tagged every class serialized, idea? thanks.
pd: if need client or server code let me know , edit post.
you sholud make members seriliazed in producto class public members , add or check thread seriliaze private member workaround c# serialize private class member
Comments
Post a Comment