mdabros / SharpLearning

Machine learning for C# .Net
MIT License
384 stars 85 forks source link

Unhandled Exception: System.Runtime.Serialization.SerializationException: The internal array cannot expand to greater than Int32.MaxValue elements. #146

Closed pjsgsy closed 10 months ago

pjsgsy commented 10 months ago

Not an issue with this code, but with .Net. Posting here simply to help others if they run across the same issue. I encountered it when trying to use the included serialisation to do a binary save of a model.

This was fixed in .Net 4.7.2, but has to be enabled with a flag

Update App.config with

<runtime>
<!-- Use this switch to make BinaryFormatter fast with large object graphs starting with .NET 4.7.2 -->
  <AppContextSwitchOverrides value="Switch.System.Runtime.Serialization.UseNewMaxArraySize=true" />
</runtime>

Problem solved.

mdabros commented 10 months ago

Thanks for adding the information here @pjsgsy!