In a question thread created late last year, forum user @Anton was asking about a binary formatter exception in relation to his attempt to use .net5.
I have just run into a similar issue. But interestingly, at around the same time that previous thread was resolved, microsoft issued a notice:
BinaryFormatter serialization methods are obsolete and prohibited in ASP.NET apps
Due to security vulnerabilities in BinaryFormatter, the following methods are now obsolete and produce a compile-time warning with ID SYSLIB0011. Additionally, in ASP.NET Core 5.0 and later apps, they will throw a NotSupportedException, unless the web app has re-enabled BinaryFormatter functionality.
BinaryFormatter.Serialize
BinaryFormatter.Deserialize
Additionally, it is now coming up to almost a year since that original thread asked about .net5, and .net6 is coming into view pretty rapidly. The performance improvements in .net5 are very significant in many cases.
Can we get .net5 support some time soon? Or at least, remove the binaryformatter
dependency? I have been developing code using .net5 and it has been working fine via visual studio, but it failed when I attempted to deploy to an azure VM. As it happens I am not writing ASP.NET, my code is a worker service deployed as a windows service, and I am getting a type initialization exception, not a not supported exception. But I believe this particular component is still the only reason why I can’t use .net5 with the solace .net API, at least when deployed to the VM.
Honestly I’m not sure why it works in visual studio, but the fix seems to be the same in both cases: get .net5 support into solace and nix their BinaryFormatter.
My own code is serializing the message payload using protobuf.net, which is much much faster anyway.
Downgrading to .net 3.1 was painful (since I was using .net5 / c# 9 features), but it did succeed. But I would say it’s “about time” we got up to current state with .net, and the binary formatter obsolescence does seem to force the issue.