[Mono-list] [Fwd: Re: Can someone analyze this code and tell me what happens]

Leonel Florin Selles leonel06013 at cfg.jovenclub.cu
Wed Apr 6 14:19:20 EDT 2011


I have put the [Serializable] attribute on the class but I steel get this

Details :

No se controló System.Runtime.Serialization.SerializationException
  Message=Se llegó al final de la secuencia antes de terminar el análisis.
  Source=mscorlib
  StackTrace:
       en System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
       en
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage methodCallMessage)
       en
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage methodCallMessage)
       en
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream)
       en server.dataStruct.DeSerialize(Byte[] listaByte) en C:\Documents
and Settings\Administrador\Mis documentos\Visual Studio
2010\Projects\server\server\dataStruct.cs:línea 65
       en server.MainClass.Main(String[] args) en C:\Documents and
Settings\Administrador\Mis documentos\Visual Studio
2010\Projects\server\server\Program.cs:línea 30
       en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,
String[] args)
       en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
       en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       en System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
ignoreSyncCtx)
       en System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
       en System.Threading.ThreadHelper.ThreadStart()
  InnerException:


That's all, and of course I get to the Heep trace.



My initial guess without the info requested by Alex is that the exception
thrown has something to do with not being able to serialize your
dataStruct instance. In that case the likely cause of the problem is that
the dataStruct class is not decorated with the [Serializable] attribute.

-SteveL


On Apr 5, 2011, at 12:28 PM, Alex <xtzgzorex at gmail.com> wrote:

> Hi,
>
> You could help us help you by telling us what exception you're
> getting. A self-contained test case also helps (the more you can
> reduce the amount of code, the better).
>
> Regards,
> Alex
>
> 2011/4/4 Leonel Florin Selles <leonel06013 at cfg.jovenclub.cu>:
>> I have created two applications that connect on the same machine and sent
>> an object, I used Socket to connect, but when the client sends data to the
>> server, and the server revived the data and try to  Deserialize is when it
>>  get me out with one exception.
>>
>> here is the client and server, the object that they use to communicate and
>>  the class to serialize and deserialize
>>
>> dataStruct
>> -----------------------------------------
>> using System;
>>
>> namespace server
>> {
          [Serializable] attribute.
>>        public class dataStruct
>>        {
>>                public dataStruct ()
>>                {
>>                }
>>
>>                public String clientName;
>>                public Int32 clientPid;
>>                public String host;
>>                public String bd;
>>                public String user;
>>                public String pass;
>>                public String usersCheck;
>>                public Boolean systemTryIcon;
>>                public String adminpass;
>>
>>                public enum signals
>>                {
>>                        ConfFileExist,
>>                        ConfFileEmpty,
>>                        SocketServerNoStart,
>>                        ClientMalCerrado,
>>                        ClientBienCerrado,
>>                        TmServiceExist,
>>                        TmServiseNoExist,
>>                        CerrarSesion,
>>                        SendMeConfData,
>>                        SaveThisConfData,
>>                        ApagerEquipo,
>>                        ReiniciarEquipo,
>>                        ObjetoBdNoInicia,
>>                        BindToSocketBrouk,
>>                        ConectarBdImposible,
>>                        SocketNoListen,
>>                        ConsultaFallo,
>>                        ConsultaOK,
>>                        ExtractConsultaFallo,
>>                        ExtractConsultaOk,
>>                        PCNoExiste
>>                }
>>
>>                public signals orden;
>>
>>        }
>> }
>>
>> ------------------------------------------------------
>>
>> Serialice
>> -----------------------------------------------------
>> using System;
>> using System.Runtime.Serialization.Formatters.Binary;
>> using System.IO;
>>
>> namespace server
>> {
>>        public class serializacion
>>        {
>>                public serializacion ()
>>                {
>>                }
>>                public static byte[] Serialize (Object objeto)
>>                {
>>                        BinaryFormatter formater = new BinaryFormatter ();
>>                        MemoryStream mem = new MemoryStream ();
>>                        formater.Serialize (mem, objeto);
>>                        return mem.GetBuffer ();
>>                }
>>                public static System.Object DeSerialize (byte[] listaByte)
>>                {
>>                        BinaryFormatter formater = new BinaryFormatter ();
>>                        MemoryStream mem = new MemoryStream ();
>>
>>                        mem.Write (listaByte, 0, listaByte.Length);
>>                        mem.Seek (0, 0);
>>                        return formater.Deserialize (mem);
>>                }
>>        }
>> }
>> ----------------------------------------------------------------
>>
>>
>> client
>> ------------------------------------
>> using System;
>> using System.Text;
>> using System.IO;
>> using System.Net.Sockets;
>>
>> namespace cliente
>> {
>>        class MainClass
>>        {
>>                public static void Main (string[] args)
>>                {
>>                        byte[] sendData;
>>                        byte[] recvData;
>>
>>                        Socket clientSocket = new Socket
(AddressFamily.InterNetwork,
>> SocketType.Stream, ProtocolType.IP);
>>                        clientSocket.Connect ("localhost", 4069);
>>
>>                        dataStruct structura = new dataStruct ();
>>
>>                        structura.clientName = "Pepe";
>>                        structura.clientPid = 1234;
>>                        structura.host = "localhost";
>>                        structura.bd = "Tmaquina";
>>                        structura.user = "TmaquinaLoco";
>>                        structura.pass = "EstoNoCuadra";
>>                        structura.usersCheck = "estudiante,florin";
>>                        structura.systemTryIcon = true;
>>                        structura.adminpass = "pepeloco";
>>                        structura.orden = dataStruct.signals.ApagerEquipo;
>>
>>                        sendData = serializacion.Serialize (structura);
>>
>>                        clientSocket.Send (sendData, 0, sendData.Length,
SocketFlags.None);
>>
>>
>>                }
>>        }
>> }
>> --------------------------------------------------
>>
>>
>>
>> Server
>> ---------------------------------------------
>> using System;
>> using System.Runtime.InteropServices;
>> using System.Net;
>> using System.Net.Sockets;
>> using System.Collections;
>> using System.Text;
>>
>> namespace server
>> {
>>        class MainClass
>>        {
>>                public static void Main (string[] args)
>>                {
>>                        byte[] sendData;
>>                        byte[] rcvData;
>>                        int puerto = 4069;
>>
>>                        Socket socketServer = new Socket
(AddressFamily.InterNetwork,
>> SocketType.Stream, ProtocolType.IP);
>>                        Socket socketClient;
>>
>>                        socketServer.Bind (new IPEndPoint
(IPAddress.Any, puerto));
>>                        socketServer.Listen (100);
>>
>>                        socketClient = socketServer.Accept ();
>>                        rcvData = new byte[4000];
>>                        socketClient.Receive (rcvData, 0,
rcvData.Length, SocketFlags.None);
>>
>>                        dataStruct datos = new dataStruct ();
>>
>>                        datos = (dataStruct)serializacion.DeSerialize
(rcvData);
>>
>>                        Console.Read ();
>>
>>                }
>>        }
>> }
>> ----------------------------------------------------------------
>>
>> helpppppppppppppppppppp
>>
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
_______________________________________________
Mono-list maillist  -  Mono-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


____________________________________________
Algunos suelen hayar su destino en el sendero que toman para evitarlo.
____________________________________________
Tu mente es como el agua, cuando esta agitada se vuelve dificir ver, pero
si dejas que se calme, la respuesta se vuelve clara.
____________________________________________
El ayer es historia, el mañana es un misterio, pero el hoy es un obcequio,
por eso se llama presente.


____________________________________________
Algunos suelen hayar su destino en el sendero que toman para evitarlo.
____________________________________________
Tu mente es como el agua, cuando esta agitada se vuelve dificir ver, pero
si dejas que se calme, la respuesta se vuelve clara.
____________________________________________
El ayer es historia, el mañana es un misterio, pero el hoy es un obcequio,
por eso se llama presente.



More information about the Mono-list mailing list