1

I dynamicaly load a dll, create a new object and serialize this object into byte array. It works fine. However I cannot deserialize this object because it throws an exception SerializationException: Unable to find assembly 'TicTacToe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Here is short code expamle

        var loadedGame = Assembly.LoadFrom(pathdll);

        var instances = from t in loadedGame.GetTypes()
                        where t.GetInterfaces().Contains(typeof(IMove))
                        select Activator.CreateInstance(t, 15) as IMove;

        IMove move = instances.First();

        var formatter = new BinaryFormatter();

        using (MemoryStream stream = new MemoryStream())
        {
            formatter.Serialize(stream, move);
            stream.Position = 0;
            formatter.Deserialize(stream); // exception is thrown here

        }

Do you have any idea how to deserialized object?

UPDATE:

Solution: How to serialize/deserialize an object loaded from another assembly?

Thanks you weston!

Community
  • 1
  • 1
Václav Starý
  • 327
  • 4
  • 11
  • 3
    Is this of use? http://stackoverflow.com/questions/8183787/how-to-serialize-deserialize-an-object-loaded-from-another-assembly – weston Mar 02 '14 at 13:14
  • Just try with [Json.Net](http://json.codeplex.com/) (`JsonConvert.SerializeObject`, `JsonConvert.PopulateObject`) It should work. – L.B Mar 02 '14 at 13:36

1 Answers1

0

Solution: How to serialize/deserialize an object loaded from another assembly?

Community
  • 1
  • 1
Václav Starý
  • 327
  • 4
  • 11