{"id":5491,"date":"2014-03-30T22:59:16","date_gmt":"2014-03-30T22:59:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-binaryformatter-collection-of-common-programming-errors\/"},"modified":"2014-03-30T22:59:16","modified_gmt":"2014-03-30T22:59:16","slug":"problem-about-binaryformatter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-binaryformatter-collection-of-common-programming-errors\/","title":{"rendered":"problem about binaryformatter-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8bfa3b6c495d0c04c70a7bdb193ac027?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDmitriy Sosunov<br \/>\nc# deserialization wif claims-based-identity binaryformatter<br \/>\nI need help to figure out why BinaryFormatter cannot deserialize identity:var identities = new[]{new ClaimsIdentity(&#8220;Bug&#8221;){Actor = new ClaimsIdentity(&#8220;Bootstrap Context as a string&#8221;){BootstrapContext = &#8220;this causes issue&#8221;},BootstrapContext = new BootstrapContext(&#8220;this raw token&#8221;)}};var sessionToken = new SessionSecurityToken(new ClaimsPrincipal(identities)); byte[] buffer; using (var ms = new MemoryStream()) {var formatter = new BinaryFormatter();formatter.Serialize(ms, sessionToken);buffer = ms<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9229412a60708763d1be5ad63a385cd3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChris Ballance<br \/>\n.net serialization binaryformatter assemblyversions<br \/>\nI have a project which uses BinaryFormatter to serialize a collection of structs with string and bool? datatypes.The serialization\/deserialization works fine, however if I were to change the assembly which does the work it fails to deserialize because of the header in the binary file indicating that it requires Assembly x instead of Assembly y to handle the data.Is it possible to setup the serialization\/deserialization to be assembly agnostic?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fddde6afcae4aa0dafbee013a1d0f7d4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMaxime Lorant<br \/>\nc# serialization binaryformatter<br \/>\nI am currently doing a game in C# (for studies purpose). I&#8217;m trying to implement a Load\/Save feature, which consist of saving every data of the game in a file, and the user can be able to reload the game saved after.In the game I have a nation class attached to each players, and every nation inherit from Nation. For the moment, I have only apply the ISerializable interface on the base class, Nation, because subclasses only have method override and no new attributes to serialize.[Serializable()]<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/86021d4144e2ba119b4929bf6b444226?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMisha<br \/>\nc# com attributes binaryformatter<br \/>\nI&#8217;m getting some external structures from COM library.I want to use BinaryFormatter and just get byte array as package. But I need special attribute on structure to satisfy BinaryFormatter.It&#8217;s not my structure so how can I handle this situation?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/931858f6d60298aeedd6fe3cd2027156?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nXBigTK13X<br \/>\nc# .net serialization deserialization binaryformatter<br \/>\nWhile trying to deserialize a file created by a BinaryFormatter, the following exception is thrown:ArgumentException: An item with the same key has already been added.The stack trace starts at the Deserialize method in BinaryFormatter, and I cannot identify what class in my code is causing the collision.I am serializing 100+ classes marked with the [Serializable] attributeI saw another question suggesting that the cause might be related to fields having duplicate names. However, I cannot find th<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8d7ecc33f727fe807606ebbe3dd8e2f0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHeather<br \/>\nc# serialization memory-mapped-files binaryformatter<br \/>\nI&#8217;m trying to serialize my MMF to file and here is the code:class MMF {private const string filename = @&#8221;c:\\NFS&#8221;;private long offset = 0;private long length = 194;private byte[] buffer;public MMF() {using (var mmf =MemoryMappedFile.CreateFromFile(filename, FileMode.OpenOrCreate, null, offset + length, MemoryMappedFileAccess.ReadWriteExecute)) {using (var accessor = mmf.CreateViewAccessor(offset, length, MemoryMappedFileAccess.ReadWriteExecute)) {buffer = new byte[194];\/*FS fs = new FS();fs.Files<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a0ce01f2067ea769784ddefb6dddc0b8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nStefan Steinegger<br \/>\nc# serialization binaryformatter<br \/>\nI have a DateRange object that represents the notion of Infinity via Static reference as shown below. As you see, the end points that define Infinity are also static references in a different class, DatePoint.Past and DatePoint.Future.Now I need to serialize this (as part of a deep Clone method that uses serialization) and know when it&#8217;s deserialized that an instance with DateTime.Min and DateTime.Max as endpoints then the instance should be DateRange.Infinity. So I think I need to make it ISeri<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dmitriy Sosunov c# deserialization wif claims-based-identity binaryformatter I need help to figure out why BinaryFormatter cannot deserialize identity:var identities = new[]{new ClaimsIdentity(&#8220;Bug&#8221;){Actor = new ClaimsIdentity(&#8220;Bootstrap Context as a string&#8221;){BootstrapContext = &#8220;this causes issue&#8221;},BootstrapContext = new BootstrapContext(&#8220;this raw token&#8221;)}};var sessionToken = new SessionSecurityToken(new ClaimsPrincipal(identities)); byte[] buffer; using (var ms = new MemoryStream()) {var formatter = new [&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-5491","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5491","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=5491"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5491\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}