How can I resolve the error BinaryFormatter serialization and deserialization are disabled within th

alberto
alberto Member Posts: 6
edited November 13 in General Discussions #1

I'm using Solace version 10.5 and we are migrating to dotnet core 8

In the following line :

ContextFactory.Instance.CreateContext(new ContextProperties(), null);

I get the exception : Exception thrown: 'System.NotSupportedException' in System.Runtime.Serialization.Formatters.dll
An exception of type 'System.NotSupportedException' occurred in System.Runtime.Serialization.Formatters.dll but was not handled in user code
BinaryFormatter serialization and deserialization are disabled within this application.

I have to mention this is the higher I can go with solace version by the way, in case the answer is to updated my version. Still I would like to know what version would resolve this.

For now I'm using the suggested fix

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- Warning: Setting the following switch is *NOT* recommended in web apps. -->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

Best Answer

  • cmorgan
    cmorgan Member, Employee Posts: 2 Solace Employee
    #2 Answer ✓

    As per the solace supported release the oldest version of cscsmp that is supported is 10.7.0. So I recommend migrating from 10.5.0. See, https://solace.com/support/support-dates-for-release-versions/
    From the solace release notes there is:

    Support New Major Version of .Net 5.0 Added support for major version upgrade of .NET to 5.x. Removed BinaryFormatter.Serialize() as this was deprecated and marked as "unsafe" by .NET.10.15.0
    

    from https://products.solace.com/download/DOTNET_API_RN.
    So version 10.15.0 would be the next version that should support this without the workaround.

    The latest version of cscsmp that officially supports net8.0 is 10.26.0.

Answers

  • cmorgan
    cmorgan Member, Employee Posts: 2 Solace Employee
    #3 Answer ✓

    As per the solace supported release the oldest version of cscsmp that is supported is 10.7.0. So I recommend migrating from 10.5.0. See, https://solace.com/support/support-dates-for-release-versions/
    From the solace release notes there is:

    Support New Major Version of .Net 5.0 Added support for major version upgrade of .NET to 5.x. Removed BinaryFormatter.Serialize() as this was deprecated and marked as "unsafe" by .NET.10.15.0
    

    from https://products.solace.com/download/DOTNET_API_RN.
    So version 10.15.0 would be the next version that should support this without the workaround.

    The latest version of cscsmp that officially supports net8.0 is 10.26.0.