Search code examples
.net-coreignite

Apache Ignite .NET Serializing delegates is not supported on this platform


Asked question about Sheduling jobs in ignite here.

Tested it with simple text output to console and with simple async web requests via HttpClient. Works fine.

Implemented real busines logic with lots of long running tasks and parallel computations.

Ignite .NET version: 2.3.0

App platform: dotnet core 2.0

But recieve exception on service registration with DeployClusterSingleton.

System.Runtime.Serialization.SerializationException: 'Serializing delegates is not supported on this platform.'

Source: System.Private.CoreLib

   at System.MulticastDelegate.GetObjectData(SerializationInfo info, StreamingContext context)
   at Apache.Ignite.Core.Impl.Binary.SerializableSerializer.WriteBinary[T](T obj, BinaryWriter writer)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.WriteBinary[T](T obj, BinaryWriter writer)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryUtils.WriteArray(Array val, BinaryWriter ctx, Nullable`1 elemTypeId)
   at Apache.Ignite.Core.Impl.Binary.BinarySystemHandlers.WriteArray(BinaryWriter ctx, Object obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.WriteBinary[T](T obj, BinaryWriter writer)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.WriteBinary[T](T obj, BinaryWriter writer)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.WriteBinary[T](T obj, BinaryWriter writer)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.WriteBinary[T](T obj, BinaryWriter writer)
   at Apache.Ignite.Core.Impl.Binary.BinaryWriter.Write[T](T obj)
   at Apache.Ignite.Core.Impl.Services.Services.<>c__DisplayClass3.<DeployMultiple>b__2(BinaryWriter w)
   at Apache.Ignite.Core.Impl.PlatformTargetAdapter.WriteToStream(Action`1 action, IBinaryStream stream, Marshaller marsh)
   at Apache.Ignite.Core.Impl.PlatformJniTarget.InStreamOutStream[TR](Int32 type, Action`1 writeAction, Func`2 readAction)
   at Apache.Ignite.Core.Impl.Services.Services.DeployMultiple(String name, IService service, Int32 totalCount, Int32 maxPerNodeCount)
   at Apache.Ignite.Core.Impl.Services.Services.DeployClusterSingleton(String name, IService service)

It is hard to guess, which part of code causing this. All i have to do is to replace code with stub part by part.

If more details is needed i can provide additional information.

After investigation:

It was IOptions<>, ILogger<>

Next one was: System.PlatformNotSupportedException: 'Operation is not supported on this platform.' from System.Reflection.RuntimePropertyInfo.GetObjectData(SerializationInfo info, StreamingContext context)

And another one was: Apache.Ignite.Core.Binary.BinaryObjectException: 'Conflicting field IDs [type=HttpClient, field1=_disposed, field2=_disposed, fieldId=375705476]'

sadly, I had to change the architecture because of this a lot;


Solution

  • This exception is caused by .NET Core, which does not support delegate serialization. Ignite just calls standard GetObjectData method.

    This would work under normal .NET 4+.

    Does your service class contain any delegates?