Skip to content

Instantly share code, notes, and snippets.

/prueba Secret
Created Feb 15, 2018

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace WindowsFormsApp2
{
[Serializable]
public class Jedi
{
public int Id { get; set; }
public string Name { get; set; }
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string cadena = "0001000000FFFFFFFF010000000000000004010000001C53797374656D2E436F6C6C656374696F6E732E486173687461626C65070000000A4C6F6164466163746F720756657273696F6E08436F6D70617265721048617368436F646550726F7669646572084861736853697A65044B6579730656616C756573000003030005050B081C53797374656D2E436F6C6C656374696F6E732E49436F6D70617265722453797374656D2E436F6C6C656374696F6E732E4948617368436F646550726F766964657208EC51383F060000000A0A0B0000000902000000090300000010020000000600000006040000000A3238373333323131353806050000000A3335353633363139303206060000000A3337353530323330333506070000000A3138373435313433363106080000000A3131303534323836393006090000000A33363330313234343234100300000006000000090A000000090B000000090C000000090D000000090E000000090F0000000C1000000044506C7567696E44657369676E2C2056657273696F6E3D312E312E312E33352C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D6E756C6C040A000000AC0153797374656D2E436F6C6C656374696F6E732E47656E657269632E4C69737460315B5B506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E7447432C20506C7567696E44657369676E2C2056657273696F6E3D312E312E312E33352C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D6E756C6C5D5D03000000065F6974656D73055F73697A65085F76657273696F6E04000043506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E7447435B5D1000000008080911000000040000000E000000010B0000000A0000000912000000040000000A000000010C0000000A00000009130000000400000008000000010D0000000A00000009140000000400000008000000010E0000000A00000009150000000400000006000000010F0000000A0000000916000000040000000600000007110000000001000000040000000441506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E74474310000000091700000009180000000919000000091A00000007120000000001000000040000000441506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E74474310000000091B000000091C000000091D000000091E00000007130000000001000000040000000441506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E74474310000000091F00000009200000000921000000092200000007140000000001000000040000000441506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E74474310000000092300000009240000000925000000092600000007150000000001000000040000000441506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E74474310000000092700000009280000000929000000092A00000007160000000001000000040000000441506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E74474310000000092B000000092C000000092D000000092E000000051700000041506C7567696E44657369676E2E53637265656E456C656D656E74732E53657175656E7469616C456C656D656E742E53657175656E7469616C456C656D656E744743020000000A5F4964456C656D656E74105F457374696D756C6F4372697469636F01000110000000062F0000000A323939353736393637330001180000001700000006300000000A313032363834323132320001190000001700000006310000000A3431313532383230323200011A0000001700000006320000000A3235323033303935363601011B0000001700000006330000000936343436393536323600011C0000001700000006340000000A3231393237313935353100011D0000001700000006350000000931363238393630343000011E0000001700000006360000000A3330333033363235393701011F0000001700000006370000000A323939353736393637330001200000001700000006380000000A313939323930333235370001210000001700000006390000000A3335303631393332353601012200000017000000063A0000000A3338323035343039343600012300000017000000063B0000000A3136303933353138303900012400000017000000063C0000000A3235373936393632383000012500000017000000063D0000000A3130323638343231323201012600000017000000063E0000000A3335393934373135303200012700000017000000063F0000000A31303735343136343233000128000000170000000640000000093834363832363533380101290000001700000006410000000A3232313534313438313100012A0000001700000006420000000A3336333839373438383700012B0000001700000006430000000A3330333033363235393700012C0000001700000006440000000A3337393035323432363001012D0000001700000006450000000A3130323638343231323200012E0000001700000006460000000A33393135313135313033000B000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
int Max = cadena.Length / 2;
byte[] Buffer = new byte[Max];
for (int i = 0; i <= Max - 1; i++)
{
Buffer[i] = Convert.ToByte(cadena.Substring(i * 2, 2), 16);
}
var hashTable = new Hashtable();
hashTable.Add(1, new Jedi { Id = 11, Name = "Yoda" });
hashTable.Add(2, new Jedi { Id = 22, Name = "Luke Skywalker" });
hashTable.Add(3, new Jedi { Id = 33, Name = "Obi-Wan Kenobi" });
hashTable.Add(4, new Jedi { Id = 44, Name = "Qui-Gon Jinn" });
var dataSerialize = ObjectToByteArray(hashTable);
string dataSerializeText = System.Text.Encoding.UTF8.GetString(dataSerialize);
Console.WriteLine("Data Serialize Byte Array: ");
Console.WriteLine(dataSerializeText);
dataSerializeText = System.Text.Encoding.UTF8.GetString(Buffer);
Console.WriteLine("\n\n\nData Serialize Byte Array: ");
Console.WriteLine(dataSerializeText+ "\n\n\n");
var hashTableUnserialize = ByteArrayToObject<Hashtable>(dataSerialize);
foreach (var key in hashTableUnserialize.Keys)
{
var jedi = (Jedi)hashTableUnserialize[key];
Console.WriteLine("Jedi {0} > {1}", jedi.Id, jedi.Name);
}
var hashTableUnserializeGenerico = ByteArrayToObjectGenerico<Hashtable>(Buffer);
}
private static byte[] ObjectToByteArray(object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream())
{
bf.Serialize(ms, obj);
return ms.ToArray();
}
}
private static T ByteArrayToObject<T>(byte[] data)
{
using (MemoryStream ms = new MemoryStream())
{
var binaryFormatter = new BinaryFormatter();
ms.Write(data, 0, data.Length);
ms.Seek(0, SeekOrigin.Begin);
T obj = (T)binaryFormatter.Deserialize(ms);
return obj;
}
}
private static T ByteArrayToObjectGenerico<T>(byte[] data)
{
using (MemoryStream ms = new MemoryStream())
{
var binaryFormatter = new BinaryFormatter();
ms.Write(data, 0, data.Length);
ms.Seek(0, SeekOrigin.Begin);
T obj = (T)binaryFormatter.Deserialize(ms);
return obj;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
@fernandezja

This comment has been minimized.

Copy link

commented Feb 16, 2018

Si ves el código en texto del objecto serializado veras que utiliza un objecto en el Hashtable dentro un objecto que es
PluginDesign.ScreenElements.SequentialElement.SequentialElementGC, PluginDesign, Version=1.1.1.35, Culture=neutral, PublicKeyToken=null
O sea necesitas dicha clase en que se encuentra en el assembly PluginDesign, Version=1.1.1.35

Puedes probar asi para ver

` string cadena = "....";

        int max = cadena.Length / 2;
        byte[] buffer = new byte[max];
        for (int i = 0; i <= max - 1; i++)
        {
            buffer[i] = Convert.ToByte(cadena.Substring(i * 2, 2), 16);
        }

        var bufferEnCadena = System.Text.Encoding.Default.GetString(buffer);

        Console.WriteLine(bufferEnCadena);`

Podras ver que tiene
PluginDesign.ScreenElements.SequentialElement.SequentialElementGC, PluginDesign, Version=1.1.1.35, Culture=neutral, PublicKeyToken=null

Esto es la cadena completa del binario serializado donde puedes ver esa parte

"\0\u0001\0\0\0����\u0001\0\0\0\0\0\0\0\u0004\u0001\0\0\0\u001cSystem.Collections.Hashtable\a\0\0\0\nLoadFactor\aVersion\bComparer\u0010HashCodeProvider\bHashSize\u0004Keys\u0006Values\0\0\u0003\u0003\0\u0005\u0005\v\b\u001cSystem.Collections.IComparer$System.Collections.IHashCodeProvider\b�Q8?\u0006\0\0\0\n\n\v\0\0\0\t\u0002\0\0\0\t\u0003\0\0\0\u0010\u0002\0\0\0\u0006\0\0\0\u0006\u0004\0\0\0\n2873321158\u0006\u0005\0\0\0\n3556361902\u0006\u0006\0\0\0\n3755023035\u0006\a\0\0\0\n1874514361\u0006\b\0\0\0\n1105428690\u0006\t\0\0\0\n3630124424\u0010\u0003\0\0\0\u0006\0\0\0\t\n\0\0\0\t\v\0\0\0\t\f\0\0\0\t\r\0\0\0\t\u000e\0\0\0\t\u000f\0\0\0\f\u0010\0\0\0DPluginDesign, Version=1.1.1.35, Culture=neutral, PublicKeyToken=null\u0004\n\0\0\0�\u0001System.Collections.Generic.List1[[PluginDesign.ScreenElements.SequentialElement.SequentialElementGC, PluginDesign, Version=1.1.1.35, Culture=neutral, PublicKeyToken=null]]\u0003\0\0\0\u0006_items\u0005_size\b_version\u0004\0\0CPluginDesign.ScreenElements.SequentialElement.SequentialElementGC[]\u0010\0\0\0\b\b\t\u0011\0\0\0\u0004\0\0\0\u000e\0\0\0\u0001\v\0\0\0\n\0\0\0\t\u0012\0\0\0\u0004\0\0\0\n\0\0\0\u0001\f\0\0\0\n\0\0\0\t\u0013\0\0\0\u0004\0\0\0\b\0\0\0\u0001\r\0\0\0\n\0\0\0\t\u0014\0\0\0\u0004\0\0\0\b\0\0\0\u0001\u000e\0\0\0\n\0\0\0\t\u0015\0\0\0\u0004\0\0\0\u0006\0\0\0\u0001\u000f\0\0\0\n\0\0\0\t\u0016\0\0\0\u0004\0\0\0\u0006\0\0\0\a\u0011\0\0\0\0\u0001\0\0\0\u0004\0\0\0\u0004APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0010\0\0\0\t\u0017\0\0\0\t\u0018\0\0\0\t\u0019\0\0\0\t\u001a\0\0\0\a\u0012\0\0\0\0\u0001\0\0\0\u0004\0\0\0\u0004APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0010\0\0\0\t\u001b\0\0\0\t\u001c\0\0\0\t\u001d\0\0\0\t\u001e\0\0\0\a\u0013\0\0\0\0\u0001\0\0\0\u0004\0\0\0\u0004APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0010\0\0\0\t\u001f\0\0\0\t \0\0\0\t!\0\0\0\t"\0\0\0\a\u0014\0\0\0\0\u0001\0\0\0\u0004\0\0\0\u0004APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0010\0\0\0\t#\0\0\0\t$\0\0\0\t%\0\0\0\t&\0\0\0\a\u0015\0\0\0\0\u0001\0\0\0\u0004\0\0\0\u0004APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0010\0\0\0\t'\0\0\0\t(\0\0\0\t)\0\0\0\t*\0\0\0\a\u0016\0\0\0\0\u0001\0\0\0\u0004\0\0\0\u0004APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0010\0\0\0\t+\0\0\0\t,\0\0\0\t-\0\0\0\t.\0\0\0\u0005\u0017\0\0\0APluginDesign.ScreenElements.SequentialElement.SequentialElementGC\u0002\0\0\0\n_IdElement\u0010_EstimuloCritico\u0001\0\u0001\u0010\0\0\0\u0006/\0\0\0\n2995769673\0\u0001\u0018\0\0\0\u0017\0\0\0\u00060\0\0\0\n1026842122\0\u0001\u0019\0\0\0\u0017\0\0\0\u00061\0\0\0\n4115282022\0\u0001\u001a\0\0\0\u0017\0\0\0\u00062\0\0\0\n2520309566\u0001\u0001\u001b\0\0\0\u0017\0\0\0\u00063\0\0\0\t644695626\0\u0001\u001c\0\0\0\u0017\0\0\0\u00064\0\0\0\n2192719551\0\u0001\u001d\0\0\0\u0017\0\0\0\u00065\0\0\0\t162896040\0\u0001\u001e\0\0\0\u0017\0\0\0\u00066\0\0\0\n3030362597\u0001\u0001\u001f\0\0\0\u0017\0\0\0\u00067\0\0\0\n2995769673\0\u0001 \0\0\0\u0017\0\0\0\u00068\0\0\0\n1992903257\0\u0001!\0\0\0\u0017\0\0\0\u00069\0\0\0\n3506193256\u0001\u0001"\0\0\0\u0017\0\0\0\u0006:\0\0\0\n3820540946\0\u0001#\0\0\0\u0017\0\0\0\u0006;\0\0\0\n1609351809\0\u0001$\0\0\0\u0017\0\0\0\u0006<\0\0\0\n2579696280\0\u0001%\0\0\0\u0017\0\0\0\u0006=\0\0\0\n1026842122\u0001\u0001&\0\0\0\u0017\0\0\0\u0006>\0\0\0\n3599471502\0\u0001'\0\0\0\u0017\0\0\0\u0006?\0\0\0\n1075416423\0\u0001(\0\0\0\u0017\0\0\0\u0006@\0\0\0\t846826538\u0001\u0001)\0\0\0\u0017\0\0\0\u0006A\0\0\0\n2215414811\0\u0001*\0\0\0\u0017\0\0\0\u0006B\0\0\0\n3638974887\0\u0001+\0\0\0\u0017\0\0\0\u0006C\0\0\0\n3030362597\0\u0001,\0\0\0\u0017\0\0\0\u0006D\0\0\0\n3790524260\u0001\u0001-\0\0\0\u0017\0\0\0\u0006E\0\0\0\n1026842122\0\u0001.\0\0\0\u0017\0\0\0\u0006F\0\0\0\n3915115103\0\v\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"`

@fernandezja

This comment has been minimized.

Copy link

commented Feb 20, 2018

Puedes crear un proyecto que se llame PluginDesign y que contenga la clase SequentialElementGC
Quedaria algo asi
`using System;

namespace PluginDesign.ScreenElements.SequentialElement
{
[Serializable]
public class SequentialElementGC
{
public string Id { get; set; }
}
}
`
y lo referencias en tu proyecto, entonces va a econtrar la clase
PluginDesign.ScreenElements.SequentialElement.SequentialElementGC

Y mira como te deserializa con los key se que se utilizaron, pero el contenido (que yo coloque como ejemplo una sola propiedad Id no lo deserializa)

deserializar-byte-en-system-collections-hashtable-002

Asi que en definitiva o adivinas que tenia o el requerimiento que tienes deberia contemplar este inconveniente de no tener la clase de destino

@markiteps

This comment has been minimized.

Copy link

commented Feb 21, 2018

La clase SequentialElementGC la conozco por un fichero pero es en .net no en c# esto podria servir de ayuda?

`Imports System.ComponentModel
Imports GestorConocimiento
Imports System.Xml.Serialization
Imports ESystem.Globalization.TypeConverters
Imports PluginDesign.Basic.ConfigurationFrames.ConfigurationControls.ElementsViewer
Imports Utiles.Log

Namespace ScreenElements.SequentialElement

''' <summary>
''' Clase envoltorio para el un elemento del Gestor de conocimiento, donde se le pueden asociar ademas otros datos como si es o no estímulo crítico.
''' Es utilizado por  <seealso cref="SequentialElement">SequentialElement</seealso>.
''' </summary>
''' <remarks>
''' Este elemento permite la serialización binaria.
''' </remarks>
<Serializable()> _
<XmlRoot("elementoSecuencial")> _
Public Class SequentialElementGC
    Implements IElementView
    Implements IStimulus


    Public Sub New()
        MyBase.New()
    End Sub


    Public Sub New(ByVal Id As String)
        MyBase.New()
        Me._IdElement = Id
    End Sub

    Private _IdElement As String = String.Empty
    <XmlAttribute("id")> _
    Public Overridable Property IdElement() As String Implements IElementView.IdElement
        Get
            Return _IdElement
        End Get
        Set(ByVal value As String)
            _IdElement = value
            If Not String.IsNullOrEmpty(value) Then
                Me._Element = Global.GestorConocimiento.Elemento.FindElemento(value)
            Else
                Me._Element = Nothing
            End If
        End Set
    End Property

    <NonSerialized()> _
    Private WithEvents _Element As Elemento
    <XmlIgnore()> _
    Public Overridable Property Element() As Elemento Implements IElementView.Element
        Get
            If Me._Element Is Nothing AndAlso Not String.IsNullOrEmpty(Me._IdElement) Then
                Me._Element = Global.GestorConocimiento.Elemento.FindElemento(Me._IdElement)
            End If
            Return _Element
        End Get
        Set(ByVal value As Elemento)
            Me._Element = value
            If value IsNot Nothing Then
                Me._IdElement = value.IdElemento
            Else
                Me._IdElement = String.Empty
            End If
        End Set
    End Property


    Private _EstimuloCritico As Boolean = False
    <XmlAttribute("esEstimuloCritico")> _
    <TypeConverter(GetType(BooleanTranslateConverter))> _
    Public Overridable Property EstimuloCritico() As Boolean Implements IStimulus.EstimuloCritico
        Get
            Return Me._EstimuloCritico
        End Get
        Set(ByVal value As Boolean)
            Me._EstimuloCritico = value
        End Set
    End Property

    <NonSerialized()> _
    Private _id As String
    <XmlAttribute("idView")> _
    Public Overridable Property Id() As String Implements Basic.ConfigurationFrames.ConfigurationControls.ElementsViewer.IElementView.Id
        Get
            If String.IsNullOrEmpty(Me._id) Then
                Return Me._IdElement
            Else
                Return _id
            End If
        End Get
        Set(ByVal value As String)
            Me._id = value
        End Set
    End Property

    Protected Overrides Sub Finalize()
        Try
            If Me._Element IsNot Nothing Then
                Try
                    Me._Element.Dispose()
                Catch ex As Exception
                    writelog(ex)
                Finally
                    Me._Element = Nothing
                End Try
            End If

            Me._EstimuloCritico = Nothing
            Me._id = Nothing
            Me._IdElement = Nothing
        Catch ex As Exception
            writelog(ex)
        Finally
            MyBase.Finalize()
        End Try


    End Sub

    Private Sub _Element_Disposing(ByVal sender As Object, ByVal e As System.EventArgs) Handles _Element.Disposing
        Me._Element = Nothing
    End Sub
End Class

End Namespace
`

@fernandezja

This comment has been minimized.

Copy link

commented Feb 21, 2018

Deje un ejemplo sencillo de un proyecto pero que no logra deserializar, por eso te decia que es una tarea "titanica"
https://github.com/fernandezja/serialization-experiments-dotnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.