Ensamblaje WPF de Visual Studio y resolución de DLL

I'm improving an existent WPF project with a TCP/IP protocol that sends and receive small objects. I'm using Visual Studio 10 but I'm stuck. I'm using BinaryFormatter to serialize the objects and until I used to send and receive with two classes in the same project I had no problem, but when I separated listener and sender (TCPListener and TCPCLient) on runtime i had this error: "Can't find Assembly 'ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'".

Googling I found out that the problem could be solved creating an external dll called from main program, but I don't know how to pass the MainWindow to the dll because the library not even can find WPF types (such as MainWindow, Combobox or Textbox)

Can you help me with this dll problem or do you have any ideas to solve the assembly reference problem?

preguntado el 05 de mayo de 13 a las 09:05

1 Respuestas

First of all, you shouldn't pass the MainWindow to a class you intend to serialize. This data class should actually not have any dependencies on the GUI. In fact, if you want to serialize a class, its public interface should in my opinion only contain primitive types or classes defined in the same assembly.

However, for a quick fix, and if you don't want to rewrite your project completely, I found that the easiest way to get the dependencies for a WPF library right was to start a new WPF application project and then change its project type to WPF Class library in the application tab of the project properties.

contestado el 05 de mayo de 13 a las 11:05

Thanks for answering. I've followed your advice but I understood the problem was in other place. I've read that Deserialization wants the same dll signature for the formatter, so I created an external dll who offers to construct the BinaryFormatter and exported it in each program path. In this way every application instance will find the same signature on both BinaryFormatters and do the serialization/deserialization in "safe" mode. I find this a little tricky (why not permit a forced Deserialization) but solved. Thanks for availability! - user2351528

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.