How do I load the same plugins from two different assemblies, and serialize and deserialize types between them? C # .net

So, I have two .net assemblies, one of which is the second Windows service. They talk using wcf with protobuf.net to serialize types.

Everything works smoothly, but I just created a primitive plugin system that loads plugins, both assemblies in my project load SUCH plugins in order to send classes inside them over the wire.

So ... 1. WPF App loads plugins (.net dll) from Assembly.LoadFrom 2. WCF App loads plugins (same .net dll) from Assembly.LoadFrom 3. Both assemblies share a dll (object library), which explicitly links to source code.

All types in an object library can be serialized from one end, traversed over the wire, and deserialized without issue.

Types in plugins can be serialized at both ends, but the other end throws an unresolved type exception when attempting to deserialize, even though they are the same type.

+3


source to share


2 answers


Found out my problem, thanks shotgun for being helpful, there would be a lot of code to show.



Basically protobuf couldn't load this type because it didn't exist in the application domain load context. Read some MSDN information to handle the AppDomain.CurrentDomain.AssemblyResolve event and return the correct assembly for plugin types.

0


source


If you want to download plugin assemblies, then MEF is an excellent solution.



0


source







All Articles