You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Orleans in docker compose. I have an orleans frontend in graphQL in a container/image and my silohost in another container/image.
This is the top of my Dockerfiles, for both frontend and silohost:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
I have migrated to C# 9 and .net 5.0 earlier this week and things were working fine.
Today I am presented with this exception in my graphQl frontend:
System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at Orleans.Serialization.BinaryFormatterSerializer.Deserialize(Type expectedType, IDeserializationContext context)
at Orleans.Serialization.BinaryFormatterISerializableSerializer.Deserialize(Type expectedType, IDeserializationContext context)
at Orleans.Serialization.SerializationManager.DeserializeInner[TContext,TReader](SerializationManager sm, Type expected, TContext context, TReader reader)
at Orleans.Serialization.BuiltInTypes.DeserializeOrleansResponse(Type expected, IDeserializationContext context)
at Orleans.Serialization.SerializationManager.DeserializeInner[TContext,TReader](SerializationManager sm, Type expected, TContext context, TReader reader)
at Orleans.Runtime.Messaging.MessageSerializer.OrleansSerializer`1.Deserialize(ReadOnlySequence`1 input, T& value)
at Orleans.Runtime.Messaging.MessageSerializer.TryRead(ReadOnlySequence`1& input, Message& message)
at Orleans.Runtime.Messaging.Connection.ProcessIncoming()
at Orleans.Internal.OrleansTaskExtentions.<ToTypedTask>g__ConvertAsync|4_0[T](Task`1 asyncTask)
at GraffQL.Schemas.BackOfficeMutation.<>c__DisplayClass19_0.<<Snipped>b__0>d.MoveNext() in Snipped\GraffQL\Schemas\BackOfficeMutation.cs:line 239
--- End of stack trace from previous location ---
at GraphQL.Execution.ExecutionStrategy.ExecuteNodeAsync(ExecutionContext context, ExecutionNode node) in C:\projects\graphql-dotnet\src\GraphQL\Execution\ExecutionStrategy.cs:line 181
My Orleans version is 3.3.0.
I have tried setting up Orleans.Serialization.ProtobufSerializer but the issue remains the same.
For now I will try to address this issue with the solution mentioned in the URL from the exception: adding the EnableUnsafeBinaryFormatterSerialization=true flag to the csproj. Hopefully that will allow me to keep using .net 5.0 (and specially c# 9).
I couldn't find mentions of BinaryFormatter here on Orleans issues, so I would like to know if I am doing anything wrong, or if this is indeed something that the awesome Orleans team needs to pick up.
Cheers and thank you for making Orleans a reality 🙏🏻
The text was updated successfully, but these errors were encountered:
Hi @fdbeirao, we will need to come up with a longer-term solution for the eventual demise of BinaryFormatter. At the moment, it is largely used as a fallback serializer, especially for serializing exceptions.
In your case, it appears that you are trying to send a type which is not marked as [Serializable] - is that correct? If so, please add the attribute to all types in your project which you need to transmit between grains. Doing so should instruct Orleans to generate serializers for those types, and BinaryFormatter can be avoided.
Hello @ReubenBond . I think you've hit the nail right in the head. The issue is indeed with exceptions. I can see that the payload does make it from graphql (frontend) into the Grain itself, but inside the grain I throw an exception. And that's where all hell breaks loose.
For now, it is okay for me to just add this snipped to both my csproj (frontend and silohost), while I wait for a more long term solution from Orleans itself:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<!-- Warning: setting the below switch is *NOT* recommended in web apps --><!-- See: https://aka.ms/binaryformatter --><!-- See: https://github.com/dotnet/orleans/issues/6805 -->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
Regarding the [Serializable], it was indeed marked. Also, I am starting to use c# 9 records and those also seem to be working fine:
Hello Orleans team,
I am using Orleans in docker compose. I have an orleans frontend in graphQL in a container/image and my silohost in another container/image.
This is the top of my Dockerfiles, for both frontend and silohost:
I have migrated to C# 9 and .net 5.0 earlier this week and things were working fine.
Today I am presented with this exception in my graphQl frontend:
My Orleans version is
3.3.0
.I have tried setting up
Orleans.Serialization.ProtobufSerializer
but the issue remains the same.For now I will try to address this issue with the solution mentioned in the URL from the exception: adding the
EnableUnsafeBinaryFormatterSerialization
=true flag to the csproj. Hopefully that will allow me to keep using .net 5.0 (and specially c# 9).I couldn't find mentions of
BinaryFormatter
here on Orleans issues, so I would like to know if I am doing anything wrong, or if this is indeed something that the awesome Orleans team needs to pick up.Cheers and thank you for making Orleans a reality 🙏🏻
The text was updated successfully, but these errors were encountered: