[BUG] System.Runtime.Serialization.SerializationException : Serializing delegates is not supported on this platform.
See original GitHub issueDescribe the bug
I trying t serialize undirected graph to binary stream. And getting exception:
Message:
System.Runtime.Serialization.SerializationException : Serializing delegates is not supported on this platform.
Stack Trace:
MulticastDelegate.GetObjectData(SerializationInfo info, StreamingContext context)
WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
ObjectWriter.Serialize(Object graph, BinaryFormatterWriter serWriter, Boolean fCheck)
BinaryFormatter.Serialize(Stream serializationStream, Object graph, Boolean check)
BinaryFormatter.Serialize(Stream serializationStream, Object graph)
SerializationExtensions.SerializeToBinary[TVertex,TEdge](IGraph`2 graph, Stream stream)
To Reproduce
[Test]
public void Test()
{
var graph = new UndirectedGraph<VertexTest, EdgeTest>();
using var stream = new MemoryStream();
QuikGraph.Serialization.SerializationExtensions.SerializeToBinary(graph, stream);
}
[Serializable]
class VertexTest
{
}
[Serializable]
class EdgeTest : IEdge<VertexTest>
{
public VertexTest Source { get; }
public VertexTest Target { get; }
}
Expected behavior Wiki says:
QuikGraph supports a wide range of targets for maximal compatibility.
.NET Standard 1.3+ .NET Core 1.0+ .NET Framework 3.5+ https://github.com/KeRNeLith/QuikGraph/wiki
I used library in .NET Core 3.1.
There is csproj of my test project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>
</Project>
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
dotnet core 2: Serializing delegates is not supported on this ...
I am trying to pass the scope (or this ) to my custom exception and show it gracefully. My code was working until...
Read more >Serializing Delegates not supported on this platform #4832
Hi There, I am running the latest version of Orleans on a docker container based upon microsoft/dotnet:2.1-runtime on linux.
Read more >BinaryFormatter serialization methods are obsolete and ...
NET libraries where serialize and deserialize methods on BinaryFormatter, Formatter, ... In .NET 7, the affected APIs are obsolete as error.
Read more >Finding source of SerializationException : r/csharp
Hello, I'm using BinarySerializer to serialize a pretty big chunk of data. ... that Serializing delegates is not supported on this platform.
Read more >Cross-Platform Support
just throws an exception, so GridGain.NET can not serialize delegates or objects containing them. Could not load file or assembly 'System.Configuration.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kreghek I finally managed to publish a new version of QuikGraph packages. Those will include fixes about the serialization of graphs not supported on .NET Core platform.
I don’t know what was your real edge structure but indeed it can produce big stuff in memory since it’s a graph with 50k edges and 100k vertices. BTW the serialization process is in the end performed by the BinaryFormatter which is quite old. As of today, it is maybe not the most efficient serializer. Do you think there really is something wrong there?
Yes but this version was already existing before your report. To have a version including the fix, we will need a new version of both QuikGraph.Serialization and QuikGraph. I didn’t make it for now. Maybe I will try to include lastest PR in this version. Is it ok for you?