Skip to content

FileNotFoundException: System.Runtime.CompilerServices.Unsafe on Unity #337

Description

@hammerimpact

LuaCSharp 0.5.5 (netstandard2.1 lib) fails to load in Unity with:

FileNotFoundException: Could not load file or assembly
'System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Lua.Internal.LuaValueDictionary.set_Item (...)
Lua.LuaTable.set_Item (...)
Lua.LuaGlobalState..ctor (...)
Lua.LuaGlobalState.Create (...)
Lua.LuaState.Create ()

Environment:

  • Unity 6000.3.21f1
  • LuaCSharp installed via NuGetForUnity, netstandard2.1 lib picked up
    (Assets/Packages/LuaCSharp.0.5.5/lib/netstandard2.1/Lua.dll)
  • packages.config does not include System.Runtime.CompilerServices.Unsafe
    by default; NuGetForUnity does not auto-resolve it

Repro:

  1. Install LuaCSharp 0.5.5 via NuGetForUnity in a Unity 6000.3.21f1 project
  2. var state = LuaState.Create();
  3. FileNotFoundException is thrown from LuaGlobalState's constructor
    (LuaValueDictionary.set_Item)

Regression note:
this same project runs this exact LuaCSharp version
without issue on Unity 6000.3.12f1. The error first appeared immediately
after upgrading the editor to 6000.3.21f1, with no other relevant project
changes. I reverted the editor back to 6000.3.12f1 (same project, same
LuaCSharp install, no other changes) and confirmed the error does not
reproduce there — it is specific to 6000.3.21f1. This strongly suggests
the missing dependency was previously being masked by some implicit
assembly version unification in the 6000.3.12f1 Mono build that the
6000.3.21f1 build no longer performs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions