Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork46
Description
Hi, seems there is a problem with dependency resolving when the application is run by SampSharp vs when is run directly.
The test case is with the nuget packageSystem.Text.Json.
If I try to use it running the server then I get an exception (details below), but if I run the program as console application then it works ok.
Exception:
System.IO.FileLoadException: 'Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)'Seems to be related to the library with the same name included in the .NET Core but it happens only with SampSharp.
I tested only on Windows.
NuGet package:System.Text.Json 7.0.3
Test code:
publicstaticvoidMain(string[]args){System.Text.Json.JsonSerializer.Deserialize("{}",typeof(object));newGameModeBuilder().Use<GameMode>().Run();}
• If I run as server without NuGet package: loaded correct version fromSERVER_FOLDER\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Text.Json.dll
• If I run as console app without NuGet package: loaded correct version fromC:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\6.0.24\System.Text.Json.dll
• If I run as console app with NuGet package: loaded correct version fromSERVER_FOLDER\gamemode\Debug\net6.0\System.Text.Json.dll
• If I run as server with NuGet package:EXCEPTION!
What I tried:
copySystem.Text.Json.dll toSERVER_FOLDER:EXCEPTION!
copySystem.Text.Json.dll toSERVER_FOLDER\dotnet\shared\Microsoft.NETCore.App\6.0.7:WORKED!
Tried another package with no name conflictNewtonsoft.Json 13.0.3 and it works ok in all cases.
Seems when running SampSharp, it is trying to resolve the assemblies in wrong order paths, it seems that is checking the .NET libraries folders first.