{"id":3912,"date":"2014-03-30T06:20:59","date_gmt":"2014-03-30T06:20:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/deserialization-exception-unable-to-find-assembly-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:20:59","modified_gmt":"2014-03-30T06:20:59","slug":"deserialization-exception-unable-to-find-assembly-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/deserialization-exception-unable-to-find-assembly-collection-of-common-programming-errors\/","title":{"rendered":"Deserialization exception: Unable to find assembly-Collection of common programming errors"},"content":{"rendered":"<blockquote>\n<p>NOTE 2: I have this same class in both assemblies<\/p>\n<\/blockquote>\n<p>No you don&#8217;t. At least, not as far as the runtime is concerned. You have two different types that happen to have the same name. A type is <strong>defined<\/strong> by its assembly. Thus &#8220;<code>SomeType<\/code> in AssemblyA&#8221; is completely different to &#8220;<code>SomeType<\/code> in AssemblyB&#8221;, even if they happen to have been compiled from the same source file.<\/p>\n<p>BinaryFormatter works with type information, so this won&#8217;t work. One option would be to move the type to a library dll that both the other projects reference &#8211; then it is only defined once, and it will be happy.<\/p>\n<p>Another option is to work with a contract-based serializer (rather than a type-based serializer). This means that &#8220;classes that look similar enough&#8221; are fine, even if they are in different assemblies (and perhaps have different source, as long as it is &#8220;similar enough&#8221;). Examples of suitable serializers for this would include (plus a few others) XmlSerializer, DataContractSerializer (but not NetDataContractSerializer), JavaScriptSerializer, or protobuf-net if you want dense raw binary.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTE 2: I have this same class in both assemblies No you don&#8217;t. At least, not as far as the runtime is concerned. You have two different types that happen to have the same name. A type is defined by its assembly. Thus &#8220;SomeType in AssemblyA&#8221; is completely different to &#8220;SomeType in AssemblyB&#8221;, even if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3912","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3912"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3912\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}