tModLoader / tModLoader

A mod to make and play Terraria mods. Supports Terraria 1.4 (and earlier) installations
https://www.tmodloader.net/
MIT License
4.19k stars 1.88k forks source link

Incorrect usage of NativeLibarary.Load I think #2110

Closed Lanboost closed 2 years ago

Lanboost commented 2 years ago

Version

Latest public-1.4-alpha

OS

Windows

Platform

Steam

This bug affects

Gameplay as a Player

Description

I have steam (and tModloader) installed on a secondary drive (E:) and Terraria runs just fine, tModloader does not. It fails to load FNA3D.dll.

In "MonoLaunch.cs" -> "ResolveNativeLibrary" NativeLibrary.TryLoad is used with a full path to a dll. I am not sure, but if I understand correctly this is not the actual use, as it will not look outside normal .dll locations not matter the path one specify. Or at least that seems to be the behaviour I am seeing.

The log file also seems to be looking in my D: drive under D:/a/ which does not even exist, so dont know what is going on there...

I managed to get it to work by compiling from source myself and adding the .dll folder to my path, the steam version still tries to look in D: however.

Did not find any other people with this issue, but I would imagine that most people run steam under C: drive.

Log File

[19:07:46] [Main Thread/INFO] [tML]: Starting tModLoader client 1.4.3.2+0.12-1.4-Alpha-ee7e1db52f1c20d9ef1f3c693e7f270176577168-5249472306838575447 [19:07:46] [Main Thread/INFO] [tML]: Log date: 2022-01-25 [19:07:46] [Main Thread/INFO] [tML]: Running on Windows X64 NetCore 6.0.1 [19:07:46] [Main Thread/INFO] [tML]: Executable: E:\steam\steamapps\common\tModLoader\tModLoader.dll [19:07:46] [Main Thread/INFO] [tML]: Working Directory: E:\steam\steamapps\common\tModLoader [19:07:46] [Main Thread/INFO] [tML]: Developer mode enabled [19:07:48] [Main Thread/DEBUG] [tML]: Native Resolve: FNA, Version=22.1.0.0, Culture=neutral, PublicKeyToken=null -> FNA3D [19:07:48] [Main Thread/DEBUG] [tML]: attempting load E:\steam\steamapps\common\tModLoader\Libraries\Native\Windows\FNA3D.dll [19:07:48] [Main Thread/WARN] [tML]: Silently Caught Exception: System.IO.FileLoadException: Failed to load Native Library at E:\steam\steamapps\common\tModLoader\Libraries\Native\Windows\FNA3D.dll at MonoLaunch.ResolveNativeLibrary(Assembly assembly, String name) in tModLoader\Terraria\MonoLaunch.cs:line 94 at System.Runtime.Loader.AssemblyLoadContext.GetResolvedUnmanagedDll(Assembly assembly, String unmanagedDllName) at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDllUsingEvent(String unmanagedDllName, Assembly assembly, IntPtr gchManagedAssemblyLoadContext) at Microsoft.Xna.Framework.Graphics.FNA3D.FNA3D_HookLogFunctions(FNA3D_LogFunc info, FNA3D_LogFunc warn, FNA3DLogFunc error) at Microsoft.Xna.Framework.FNALoggerEXT.HookFNA3D() in D:\a\tModLoader\tModLoader\FNA\src\FNALoggerEXT.cs:line 65 at Microsoft.Xna.Framework.FNAPlatform..cctor() in D:\a\tModLoader\tModLoader\FNA\src\FNAPlatform\FNAPlatform.cs:line 143 at Microsoft.Xna.Framework.Game.InitializeClientFeatures() in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 756 at Microsoft.Xna.Framework.Game..ctor(Boolean headlessMode) in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 272 at Terraria.Main..ctor() in tModLoader\Terraria\Main.cs:line 4937 at Terraria.Program.LaunchGame(Boolean isServer) in tModLoader\Terraria\Program.cs:line 201 at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 174 at MonoLaunch.<>c__DisplayClass2_0.

b__0() in tModLoader\Terraria\MonoLaunch.cs:line 60 at System.Threading.Thread.StartCallback()

[19:07:48] [Main Thread/WARN] [tML]: Silently Caught Exception: System.TypeInitializationException: The type initializer for 'Microsoft.Xna.Framework.FNAPlatform' threw an exception. at Microsoft.Xna.Framework.Game.InitializeClientFeatures() in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 756 at Microsoft.Xna.Framework.Game..ctor(Boolean headlessMode) in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 272 at Terraria.Main..ctor() in tModLoader\Terraria\Main.cs:line 4937 at Terraria.Program.LaunchGame_(Boolean isServer) in tModLoader\Terraria\Program.cs:line 201 at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 174 at MonoLaunch.<>c__DisplayClass2_0.

b__0() in tModLoader\Terraria\MonoLaunch.cs:line 60 at System.Threading.Thread.StartCallback()

[19:07:48] [Main Thread/FATAL] [Terraria]: Main engine crash System.TypeInitializationException: The type initializer for 'Microsoft.Xna.Framework.FNAPlatform' threw an exception. ---> System.IO.FileLoadException: Failed to load Native Library at E:\steam\steamapps\common\tModLoader\Libraries\Native\Windows\FNA3D.dll at MonoLaunch.ResolveNativeLibrary(Assembly assembly, String name) in tModLoader\Terraria\MonoLaunch.cs:line 94 at System.Runtime.Loader.AssemblyLoadContext.GetResolvedUnmanagedDll(Assembly assembly, String unmanagedDllName) at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDllUsingEvent(String unmanagedDllName, Assembly assembly, IntPtr gchManagedAssemblyLoadContext) at Microsoft.Xna.Framework.Graphics.FNA3D.FNA3D_HookLogFunctions(FNA3D_LogFunc info, FNA3D_LogFunc warn, FNA3DLogFunc error) at Microsoft.Xna.Framework.FNALoggerEXT.HookFNA3D() in D:\a\tModLoader\tModLoader\FNA\src\FNALoggerEXT.cs:line 65 at Microsoft.Xna.Framework.FNAPlatform..cctor() in D:\a\tModLoader\tModLoader\FNA\src\FNAPlatform\FNAPlatform.cs:line 143 --- End of inner exception stack trace --- at Microsoft.Xna.Framework.Game.InitializeClientFeatures() in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 756 at Microsoft.Xna.Framework.Game..ctor(Boolean headlessMode) in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 272 at Terraria.Main..ctor() in tModLoader\Terraria\Main.cs:line 4937 at Terraria.Program.LaunchGame(Boolean isServer) in tModLoader\Terraria\Program.cs:line 201

Steps to reproduce

  1. Download terraria
  2. Download tModloader
  3. Start tModloader
  4. Profit???

Expected Behavior

To be able to play

Actual Behavior

Crash

Reproduction frequency

Always

Additional Information

No response

Solxanich commented 2 years ago

Please direct all support queries to the # (alpha) support channel of the tmodloader discord, per the option presented when creating issues. (https://discord.gg/xFpbKkJ3) It has active support available, and it is very unlikely you will receive a support response here.

With respect to your particular issue, all libraries are provided with the install. The TryLoad fails due to an unmanaged error in the FNA3D library. You can try asking in the discord.

Solxanich commented 2 years ago

Discussed in Discord. The issue stems from a messy windows PATH, which leads to loading the wrong version of SDL2 by FNA3D. This follows the same pattern seen on Unix which has a system SDL2 installed.

The workaround for a particular user is to correct the PATH to detect SDL2 from tmodloader, and not from other locations.

A fix for tmodloader itself will be tabled in due time after investigating what to do about it.

dedisvoin commented 2 years ago

не удалось запустить.

Solxanich commented 2 years ago

Fixed in 0202492559590b6ee2e51ab24771aeafa6bc5997