I wrote a plugin system and I want to save/load their properties so that if the program is restarted they can continue working. I use binary serialization. The problem is they can be serialized but not deserialized. During the deserialization "Unable to find assembly" exception is thrown. How can I restore serialized data?
Serializing and Deserializing External Assembly in C#
3.5k Views Asked by Selçuk Öztürk At
3
There are 3 best solutions below
1
On
More than likely, your plugin assembly is not loaded at the time that you're deserializing the data. Because it's an external, plugin assembly, I'm guessing you're explicitly loading it. You are probably deserializing the properties object before loading the assembly. You can diagnose and fix the problem by hooking the AssemblyResolve and AssemblyLoad events on the current AppDomain and observing exactly when they're called.
You can also use AssemblyResolve to fix the load error by putting explicit Assembly load code in it yourself and returning the loaded assembly. I don't recommend this because it's kindof backwards.
Ok here I have found something. :)
http://techdigger.wordpress.com/2007/12/22/deserializing-data-into-a-dynamically-loaded-assembly/
I used this approach and it worked without any problem.
Firs defined a binder class:
And then serialization methods:
And I use them where I need.
Thanks for help :)