Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialization of Generic class throws InvalidCastException #100

Open
marko-savic opened this issue Jul 5, 2018 · 2 comments
Open

Deserialization of Generic class throws InvalidCastException #100

marko-savic opened this issue Jul 5, 2018 · 2 comments

Comments

@marko-savic
Copy link

marko-savic commented Jul 5, 2018

I'm using Akka.Serialization.Hyperion 1.1.3.32-beta,
On receiver side i never receive message when message contains Maybe<MyCustomClass> due deserialization exception.

Is this problem may be related to Hyperion or i need to register custom serializer or something i'm missing?

Stack trace:
System.InvalidCastException: Unable to cast object of type 'Common.Types.Maybe1[Domain.Models.Vending.Devices.States.DoorSensorState]' to type 'Domain.Models.Vending.Devices.States.DoorSensorState'.\r\n at lambda_method(Closure , Stream , DeserializerSession )\r\n at lambda_method(Closure , Stream , DeserializerSession )\r\n at Hyperion.SerializerFactories.EnumerableSerializerFactory.<>c__DisplayClass5_0.<BuildSerializer>b__1(Stream stream, DeserializerSession session)\r\n at lambda_method(Closure , Stream , DeserializerSession )\r\n at Hyperion.Serializer.Deserialize[T](Stream stream)\r\n at Akka.Serialization.HyperionSerializer.FromBinary(Byte[] bytes, Type type)\r\n at Akka.Serialization.Serialization.Deserialize(Byte[] bytes, Int32 serializerId, String manifest)\r\n at Akka.Remote.DefaultMessageDispatcher.Dispatch(IInternalActorRef recipient, Address recipientAddress, SerializedMessage message, IActorRef senderOption)\r\n at Akka.Remote.EndpointReader.<Reading>b__11_1(InboundPayload inbound)\r\n at lambda_method(Closure , Object , Action1 , Action1 , Action1 )\r\n at Akka.Tools.MatchHandler.PartialHandlerArgumentsCapture4.Handle(T value)\r\n at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message, PartialAction1 partialAction)\r\n at Akka.Actor.UntypedActor.Receive(Object message)\r\n at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)\r\n at Akka.Actor.ActorCell.ReceiveMessage(Object message)\r\n at Akka.Actor.ActorCell.Invoke(Envelope envelope)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Akka.Actor.ActorCell.HandleFailed(Failed f)\r\n at Akka.Actor.ActorCell.SysMsgInvokeAll(EarliestFirstSystemMessageList messages, Int32 currentState)",

@Horusiath
Copy link
Contributor

@marko-savic could you isolate this exception and provide some reproducible example?

@marko-savic
Copy link
Author

I have tried simple test only with latest Hyperion and struct Maybe<T> . Everything seems to work correct. However when using Akka.Serialization.Hyperion 1.1.3.32-beta within actor system i got System.InvalidCastException.

So simple working example is communication between two actors in CLR. Just turn on serialization for every message:
akka { actor { serialize-messages = on } }

And send one message like this:

class TestMessage { Maybe<MyTestClass> testField = Maybe<MyTestClass>.From(new MyTestClass()); } public MyTestClass { }

where Maybe<T> is struct provided in a file.
Maybe.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants