MonoMod / MonoMod.Common

Common code used by MonoMod and other .NET modding libraries. Not to be confused with MonoMod.Utils (for mods).
MIT License
75 stars 33 forks source link

DynDll does not work with non-ASCII characters in path #42

Open NotNite opened 7 months ago

NotNite commented 7 months ago

See: https://github.com/SlopCrew/SlopCrew/issues/134

My mod Slop Crew uses DynDll to load GameNetworkingSockets inside of Unity. When the path to the library contains non-ASCII characters, a cryptic error is thrown:

[Error  : Unity Log] EntryPointNotFoundException: No matching entry point found for GameNetworkingSockets_Init in SlopCrew.Common.Native
Stack trace:
MonoMod.Utils.DynDll.InternalResolveDynDllImports (System.Type type, System.Object instance, System.Collections.Generic.Dictionary`2[TKey,TValue] mappings) (at <6733e342b5b549bba815373898724469>:0)
MonoMod.Utils.DynDll.ResolveDynDllImports (System.Type type, System.Collections.Generic.Dictionary`2[TKey,TValue] mappings) (at <6733e342b5b549bba815373898724469>:0)
SlopCrew.Common.Native..cctor () (at D:/code/c#/brc/SlopCrew/SlopCrew.Common/ValveSockets.cs:909)
Rethrow as TypeInitializationException: The type initializer for 'SlopCrew.Common.Native' threw an exception.
SlopCrew.Common.Library.Initialize (System.Text.StringBuilder errorMessage) (at D:/code/c#/brc/SlopCrew/SlopCrew.Common/ValveSockets.cs:830)
SlopCrew.Common.Library.Initialize () (at D:/code/c#/brc/SlopCrew/SlopCrew.Common/ValveSockets.cs:819)

(For the sake of testing, I renamed Bomb Rush Cyberfunk to Bómb Rush Cyberfunk.)

This is a problem because r2modman installs profiles into AppData by default, so users with non-ASCII characters in their Windows username will not be able to use my mod.