cloudscribe/cloudscribe.Web.Navigation

NotSupportedException: BinaryFormatter

Closed this issue ยท 6 comments

mmu69 commented

After upgrading my dotnet core 3.1 project to dotnet core 5.0 i got an error when runnig the application (builds with no problem).

An unhandled exception occurred while processing the request.

NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, object graph)

There are two ways to work around this issue:

  1. Disable the Distributed Cache in favour of Memory Cache:
services.AddScoped<ITreeCache, MemoryTreeCache>();  // Must come after .AddCloudscribeNavigation
  1. Temporarily re-enable BinaryFormatter by adding the following to your project file:
<PropertyGroup>
  <TargetFramework>net5.0</TargetFramework>
  <!-- Warning: setting the below switch is *NOT* recommended in web apps -->
  <!-- See: https://aka.ms/binaryformatter -->
  <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

However, as the warnings suggest this is not something that should be considered a proper solution - this library will need to be updated to not use BinaryFormatter.

@richardlawley @mmu69 we're looking into it this week.

Library cloudscribe.Web.Navigation is now updated to v4.1.1 and removes that binaryFormatter usage.

I still have additional work to do updating 10 other higher-level CS libraries that reference it (eg simpleContent.Web), so there's consistent versioning up through the dependency chain. (That won't be today.)

@mmu69 @richardlawley ready for testing.

Several higher level NuGets (which consume the modified cloudscribe.Web.Navigation)
are now updated.

Most notably
cloudscribe.Core.Web 4.1.4
cloudscribe.simpleContent.Web 5.1.1

Checked that a new template solution builds and runs.
I tried updating its TargetFramework to net5.0 - built and runs without runtime errors.

mmu69 commented

The BinaryFormatter error when running a net 5 project with cloudscribe.web.navigation is solved.