BinaryFormatter exception in .Net 5
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 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, EventHandler1 contextEventHandler) at SolaceSystems.Solclient.Messaging.Native.ContextFactoryImpl.CreateContext(ContextProperties contextProperties, EventHandler
1 contextEventHandler)
at SolaceSystems.Solclient.Messaging.Adapter.ContextFactoryAdapter.CreateContext(ContextProperties contextProperties, EventHandler1 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
Comments
-
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.
0 -
@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.
0 -
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
-Marc0 -
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?
0 -
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.
1 -
Hi @amackenzie . Thanks, looks like I somehow overlooked this. Btw, where is it possible to check changelogs for new releases?
0 -
Hello,
The API release notes are included with the download packages and also part of our docs. Here is the .Net version:
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 the10.15.0
you are actually looking for.We are looking at changing our release notes to include history. I will tag @palidhjede , our API product manager so he is aware of another person interested in the history in release notes.
0 -
@amackenzie thank you. It would be great if you'll follow common pattern and upload release notes to NuGet.org - it will be much easier to find. Like here https://www.nuget.org/packages/Nuke.Common/6.0.0 (there is a Release Notes tab)
0