sentry-unity icon indicating copy to clipboard operation
sentry-unity copied to clipboard

Assembly Alias causes `System.Text.Json` exception

Open bitsandfoxes opened this issue 1 year ago • 3 comments

Steps to reproduce:

  1. Build the SDK with TFM netstandard2.1 (i.e. using Unity 2022 or newer)
  2. Run the aliasing tool
  3. Attempt to capture an error, session, transaction
  4. Observe the following error while the SDK attempts to serialize an envelope
TypeLoadException: VTable setup of type System.Text.Json.Utf8JsonWriter failed

This does not happen when skipping the aliasing step.

bitsandfoxes avatar Aug 27 '24 16:08 bitsandfoxes

As workarounds:

  1. Use version Unity 2021 or older to build the SDK - and that's how CI does it
  2. Disable aliasing when packing/repacking the SDK

bitsandfoxes avatar Aug 27 '24 16:08 bitsandfoxes

Workaround #1 won't work for us, so I attempted workaround #2. It worked in editor, but when I did a player build, it crashes with a new error:

System.Text.Json.Utf8JsonWriter doesn't implement interface System.IAsyncDisposable

sambonfire avatar Aug 27 '24 23:08 sambonfire

Since we're SOL on this one, I'll try my luck and see if @xoofx has any idea what might be going on 🙏

tl;dr: Same code base, if we build with netstandard2.1 (i.e. using Unity 2022 or newer) it crashes. Works if we build with ns2.0.

bruno-garcia avatar Sep 11 '24 00:09 bruno-garcia