# BinaryFormatter exception in .Net 5

**URL:** <https://community.solace.com/t/binaryformatter-exception-in-net-5/531>\
**Category:** General Discussions\
**Tags:** net, c\
**Created:** [December 23, 2020, 3:34pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531 "2020-12-23T15:34:29Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [December 23, 2020, 3:34pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/1 "2020-12-23T15:34:29Z")

</div>

Hi,  
after migrating project to .Net 5 we started to get this error:

System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See [Deserialization risks in use of BinaryFormatter and related types - .NET | Microsoft Learn](https://aka.ms/binaryformatter) for more information.  
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) at SolaceSystems.Solclient.Utils.Types.Utilities.DeepCopy[T](T source)  
at SolaceSystems.Solclient.Messaging.BaseProperties.Clone()  
at SolaceSystems.Solclient.Messaging.Native.ContextImpl…ctor(ContextProperties ctxProps, EventHandler`1 contextEventHandler) at SolaceSystems.Solclient.Messaging.Native.ContextFactoryImpl.CreateContext(ContextProperties contextProperties, EventHandler`1 contextEventHandler)  
at SolaceSystems.Solclient.Messaging.Adapter.ContextFactoryAdapter.CreateContext(ContextProperties contextProperties, EventHandler`1 contextEventHandler) at SolaceSystems.Solclient.Messaging.ContextFactory.CreateContext(ContextProperties contextProperties, EventHandler`1 contextEventHandler)

This can be turned off by adding true to the project file. But this obviously can’t be used as a long-term solution. When can we expect new NuGet package with this properly solved on your side?

Thanks

---

<div class="post-metadata">

**Author:** ![TomF](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tomf/32/1749_2.png) [@TomF](https://community.solace.com/u/TomF)\
**Post date:** [December 23, 2020, 5:39pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/2 "2020-12-23T17:39:04Z")

</div>

Hi @Anton, we don’t _officially_ support .Net 5 yet but it’s on our roadmap. I’ll let @amackenzie comment further on due dates as he’s better placed to do that. Support for .Net 5 should fix BinaryFormatter.

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [December 26, 2020, 5:19pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/3 "2020-12-26T17:19:30Z")

</div>

Hi,

What do you mean by do not officially support? It’s a netstandard 2.0 library, so I assume that it should still work nicely with .Net 5?

Regards

---

<div class="post-metadata">

**Author:** ![TomF](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tomf/32/1749_2.png) [@TomF](https://community.solace.com/u/TomF)\
**Post date:** [January 4, 2021, 5:02pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/4 "2021-01-04T17:02:19Z")

</div>

Hi @Anton, I meant that Solace doesn’t support .Net 5 yet.

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [January 5, 2021, 2:12pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/5 "2021-01-05T14:12:33Z")

</div>

Sorry, but I still don’t get it. Besides that BinaryFormatter issue for which we have workaround what could it be else? SolaceSystems.Solclient.Messaging is a netstandard2 lib so it should work nicely in .Net 5.

---

<div class="post-metadata">

**Author:** ![TomF](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tomf/32/1749_2.png) [@TomF](https://community.solace.com/u/TomF)\
**Post date:** [January 5, 2021, 3:03pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/6 "2021-01-05T15:03:25Z")

</div>

@Anton yes good point: I probably should have said “officially supported” - so technically it will work but if you see a bug, the answer from our support/R&D team will be “we will do our best, but can’t guarantee anything.” We do plan to officially support it soon.

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [January 27, 2021, 1:43pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/7 "2021-01-27T13:43:41Z")

</div>

@TomF I see that new version of SolaceSystems.Solclient.Messaging was release about 13 days ago. Does it have fix for .Net 5? Also, is there any release notes for the new versions?

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [January 27, 2021, 1:59pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/8 "2021-01-27T13:59:04Z")

</div>

Hi @Anton,  
I haven’t gotten a chance to review the release notes myself for your particular fix but you can find the release notes alongside the API on our downloads page: [https://solace.com/downloads/?fwp\_downloads=solace-apis](https://solace.com/downloads/?fwp_downloads=solace-apis)  
-Marc

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [January 27, 2021, 2:03pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/9 "2021-01-27T14:03:24Z")

</div>

@marc thanks, looks like it didn’t make it to this release.

---

<div class="post-metadata">

**Author:** ![allmhhuran](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/allmhhuran/32/2272_2.png) [@allmhhuran](https://community.solace.com/u/allmhhuran)\
**Post date:** [September 28, 2021, 10:53am UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/10 "2021-09-28T10:53:50Z")

</div>

Yikes, I have just run into this problem myself.

I’ve been developing on my machine for while under .net5 with no issues. No complaints or warnings from visual studio on build, all tests passed, etc.

But I’ve just deployed to an azure VM to run as a service in production, and I get

> Exception Info: System.TypeInitializationException: The type initializer for ‘System.Runtime.Serialization.Formatters.Binary.Converter’ threw an exception.

The last call in the stack that references the solace libraries at `SolaceSystems.Solclient.Utils.Types.Utilities.DeepCopy[T](T source)`

This is something of an issue. And whoa… we’re 8 months on from where this thread ended. Are we still not .net5 compatible?

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [February 9, 2022, 10:47am UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/11 "2022-02-09T10:47:37Z")

</div>

Hi,  
it’s been more than a year since I reported this issue. Are you guys looking at fixing it at all?  
Regards

---

<div class="post-metadata">

**Author:** ![amackenzie](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/amackenzie/32/1168_2.png) [@amackenzie](https://community.solace.com/u/amackenzie)\
**Post date:** [February 9, 2022, 3:27pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/12 "2022-02-09T15:27:53Z")

</div>

Hello @Anton ,  
Have you updated your package in Nuget? We addressed this in v10.15.0 and the following was the release note:  
Added support for major version upgrade of .NET to 5.x. Removed BinaryFormatter.Serialize() as this was deprecated and marked as “unsafe” by .NET. If this continues to be an issue after upgrading to v10.15.0 (or above, 10.16.0 is out now), please let us know.

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [February 9, 2022, 3:34pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/13 "2022-02-09T15:34:12Z")

</div>

Hi @amackenzie . Thanks, looks like I somehow overlooked this. Btw, where is it possible to check changelogs for new releases?

---

<div class="post-metadata">

**Author:** ![amackenzie](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/amackenzie/32/1168_2.png) [@amackenzie](https://community.solace.com/u/amackenzie)\
**Post date:** [February 9, 2022, 3:58pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/14 "2022-02-09T15:58:56Z")

</div>

Hello,  
The API release notes are included with the download packages and also part of our docs. Here is the .Net version:  
C# / .NET API ([solace.com](http://solace.com))  
However, at this time, these only show the changes made in the latest version and do not contain the historical changes. e.g. you can see the 10.16.0 changes at that link but not the 10.15.0 you are actually looking for.  
We are looking at changing our release notes to include history. I will tag @murat , our API product manager so he is aware of another person interested in the history in release notes.

---

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://community.solace.com/u/Anton)\
**Post date:** [February 9, 2022, 4:06pm UTC](https://community.solace.com/t/binaryformatter-exception-in-net-5/531/15 "2022-02-09T16:06:06Z")

</div>

@amackenzie thank you. It would be great if you’ll follow common pattern and upload release notes to [NuGet.org](http://NuGet.org) - it will be much easier to find. Like here [NuGet Gallery | Nuke.Common 6.0.0](https://www.nuget.org/packages/Nuke.Common/6.0.0) (there is a Release Notes tab)
