Skip to content

System.MissingFieldException is raised when connect failed in NativeAOT app #3157

Description

@itn3000

Environment

  • StackExchange.Redis versoin: 3.1.3
  • TargetFramework: net10.0
  • Platform: win-x64

Steps to reproduce

  1. create new project by dotnet new worker
  2. add nuget package by dotnet add package StackExchange.Redis
  3. edit Worker.cs as https://gist.github.com/itn3000/bc6c9282a33f455cf7621d5ff86560de
  4. publish by dotnet publish -p:PublishAot=true -r win-x64
  5. run published app

Expected

output connection error and keep worker running

Actual

output following error and stop entire app

Unhandled exception. System.MissingFieldException: Field not found: '_invocationList'.
   at StackExchange.Redis.Delegates.s_getArr(MulticastDelegate) + 0x15
   at StackExchange.Redis.ConnectionMultiplexer.TryCompleteHandler[T](EventHandler`1, Object, T, Boolean) + 0x4b
   at StackExchange.Redis.ConnectionFailedEventArgs.StackExchange.Redis.ICompletable.TryComplete(Boolean) + 0x22
   at StackExchange.Redis.ConnectionMultiplexer.<>c.<.cctor>b__85_0(Object) + 0x22
   at System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x16a
   at System.Threading.WindowsThreadPool.DispatchCallback(IntPtr, IntPtr, IntPtr) + 0x60

Additional Info

if NativeAOT is disabled, app works as expected.
This is reproduced in 3.0.25, but not reproduced in 2.13.17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions