Skip to content

Using MessagePack with SignalR on IL2CPP #973

Closed

Description

@thorgeirk11

Bug description

I am using Unity to create a multiplayer game using SignalR and MessagePack. I have created a Generated Resolver which works perfectly using Mono.

I am using Microsoft.AspNetCore.SignalR.Protocols.MessagePack for my client/server which has a dependency on MessagePack.dll. The issue is that If I use the base MessagePack.dll I get the following error

PlatformNotSupportedException: Operation is not supported on this platform.
  at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.Resolvers.DynamicEnumResolver..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.Internal.StandardResolverHelper..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.Resolvers.StandardResolver..cctor () [0x00000] in <00000000000000000000000000000000>:0 

I posted an issue on the asp.net github but after further investigation, I found that MessagePack has native support for Unity (IL2CPP) which inherently is not compatible with SignalR.

Is there any way for me to make these two solutions work together?

Activity

  1. jsteinich commented on Jul 7, 2020

    @jsteinich
    Contributor

    I haven't tried with SignalR, but we have a similar situation with an internal shared library.

    We have everything working, but it required building our own version of MessagePack.dll. We basically turn on the compile flags that would normally be set by Unity and build.

    There have been/are a couple proposals about how to make the support better, but working around Unity's restrictions has made it tough to find an approach that meets all criteria.

  2. youtpout commented on Jul 17, 2020

    @youtpout

    Same problem here I can't use MessagePack with SignalR and Unity.
    @jsteinich can you share your working messagepack dll ?

  3. jsteinich commented on Jul 17, 2020

    @jsteinich
    Contributor

    MessagePack_nuget.zip
    Zip contains nuget packages.

    Unity often gets mad if dll versions don't match, so those may not work for you.

  4. youtpout commented on Jul 19, 2020

    @youtpout

    Thank you but I have a problem for deserialize object.
    If I transport complex object the deserialization doesn't work in Unity.
    I give up, i lost 3 days on unity implementation, i use the integrate serialization in SignalR who works like a charm for the moment.

  5. neuecc commented on Aug 5, 2020

    @neuecc
    Member

    same as #977, I'll write fixed code soon.

  6. thorgeirk11 commented on Aug 12, 2020

    @thorgeirk11
    ContributorAuthor

    @neuecc @AArnott I can verify that this issue is fixed. Is there any ETA on the next version update?

  7. jsteinich commented on Aug 12, 2020

    @jsteinich
    Contributor

    One thing to watch out for is #931 since there is code behind a UNITY_ANDROID flag.

  8. added this to the v2.1 milestone on Aug 12, 2020
  9. AArnott commented on Aug 12, 2020

    @AArnott
    Collaborator

    I just released 2.1.165.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions