Using .NET 6 to Run DW2 Natively On Linux
Long shot, but with the following:
This release includes an (optional) launcher that makes the game use .NET 6 instead of the old .NET Framework v4.6.1
Would this allow the game to run natively on Linux given that .net 6 is available natively on Linux? I tried naively just running the binary through dotnet 6.0.2 but my C#/.NET experience is so limited I don't even know if I've setup my .net install correctly to make sense of the error I got, which was the following:
Unhandled exception. System.BadImageFormatException: Could not load file or assembly '(...)/DW2Net6Win.exe'. The module was expected to contain an assembly manifest. File name: '(...)/DW2Net6Win.exe'
The launcher executable is 'published' with the runtime target of win-x64. You can check out the project and built it with the linux-x64 target, but I doubt it will work.
Most of the Xenko engine components are platform agnostic and to that end are .NET Standard, but there would need to be several patches to emulate some of the windows specific additions, specifically the native method calls.
That said, I don't think it's too far fetched to make the attempt in the future at making it run on Linux or other platforms.
I was able to run DW2 on linux in wine using .NET 6.0.3 runtime (without installing .NET 4.x) + dxvk and play continuously for 3-4 hours without crashes.
For .NET 6 to work on wine I had to compile wine with the patch attached here: https://bugs.winehq.org/show_bug.cgi?id=52396 dxvk was installed through winetricks.
In addition to .NET 6, I've used this mod to make textures take less VRAM: https://github.com/froce/DW2TextureCruncher/releases (follow instructions listed there "Unzip to your "Distant World 2\mods" directory")
For DW2TextureCruncher to work I had to copy DW2TextureCruncher.exe and texconv.exe from the mod directory to the base game directory (where other executables are) and run it from there.
WINEPREFIX=~/games/dw2 wine DW2TextureCruncher.exe .
If you're using DXVK, add DW2MC_DX11_DEVICE_LOCKS=1 as an environment variable for some more stability. :)
Is there a way to disable AppContainer isolation environment? It fails on Linux and asks for a key to continue after the warning, which prevents automatic launch using Lutris. I can probably work around that manually, but a way to disable it would be best.
Unable to find an entry point named 'CreateAppContainerProfile' in DLL 'userenv.dll'.
at NtApiDotNet.Win32.Win32NativeMethods.CreateAppContainerProfile(String pszAppContainerName, String pszDisplayName, String pszDescription, SidAndAttributes[] pCapabilities, Int32 dwCapabilityCount, SafeSidBufferHandle& ppSidAppContainerSid)
at NtApiDotNet.Win32.AppContainerProfile.Create(String appcontainer_name, String display_name, String description, IEnumerable`1 capabilities, Boolean throw_on_error)
at NtApiDotNet.Win32.AppContainerProfile.Create(String appcontainer_name, String display_name, String description, IEnumerable`1 capabilities)
at DW2Net6Win.Isolation.Windows.StartIsolatedProcess(String appContainerName, String path, String[] commandLineArguments, IEnumerable`1 capabilitySids, Boolean attachToCurrentProcess, IEnumerable`1 fileAccess, String workingDirectory)
at Launcher.Run(String[] args)
=== === === === === === WARNING === === === === === ===
Failed to create AppContainer isolation environment!
You may need to run this executable as admin in order to
run the game isolated. Without AppContainer isolation,
it may be unsafe to run the game with modifications.
If you wish to continue without isolation, press the
[F5] key. The exception above has some clue as to why
the failure occurred, it is likely that directory
permissions are already more restricted than the
launcher expected for the current user.
=== === === === === === WARNING === === === === === ===
Press any key to exit.
Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
at System.ConsolePal.ReadKey(Boolean intercept)
at System.Console.ReadKey(Boolean intercept)
at Launcher.Run(String[] args)
at Program.Main(String[] args)
Oh I see. Can you run expect to send key input?
I'll try to detect missing input and give a popup or something.
You can try the latest artifact from GitHub actions. It might have this fixed.
On Thu, Apr 7, 2022, 1:52 AM 0cc4m @.***> wrote:
Is there a way to disable AppContainer isolation environment? It fails on Linux and asks for a key to continue after the warning, which prevents automatic launch using Lutris. I can probably work around that manually, but a way to disable it would be best.
Unable to find an entry point named 'CreateAppContainerProfile' in DLL 'userenv.dll'. at NtApiDotNet.Win32.Win32NativeMethods.CreateAppContainerProfile(String pszAppContainerName, String pszDisplayName, String pszDescription, SidAndAttributes[] pCapabilities, Int32 dwCapabilityCount, SafeSidBufferHandle& ppSidAppContainerSid) at NtApiDotNet.Win32.AppContainerProfile.Create(String appcontainer_name, String display_name, String description, IEnumerable
1 capabilities, Boolean throw_on_error) at NtApiDotNet.Win32.AppContainerProfile.Create(String appcontainer_name, String display_name, String description, IEnumerable1 capabilities) at DW2Net6Win.Isolation.Windows.StartIsolatedProcess(String appContainerName, String path, String[] commandLineArguments, IEnumerable1 capabilitySids, Boolean attachToCurrentProcess, IEnumerable1 fileAccess, String workingDirectory) at Launcher.Run(String[] args) === === === === === === WARNING === === === === === === Failed to create AppContainer isolation environment! You may need to run this executable as admin in order to run the game isolated. Without AppContainer isolation, it may be unsafe to run the game with modifications. If you wish to continue without isolation, press the [F5] key. The exception above has some clue as to why the failure occurred, it is likely that directory permissions are already more restricted than the launcher expected for the current user. === === === === === === WARNING === === === === === ===Press any key to exit.Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read. at System.ConsolePal.ReadKey(Boolean intercept) at System.Console.ReadKey(Boolean intercept) at Launcher.Run(String[] args) at Program.Main(String[] args)
— Reply to this email directly, view it on GitHub https://github.com/DW2MC/DW2ModLoader/issues/1#issuecomment-1091107474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIC7PYG2HB2MB2UPYXEVCWDVDZZZLANCNFSM5RFEIDNA . You are receiving this because you commented.Message ID: @.***>
Thank you for the quick response! The disableIsolation variable gets set by default now, I think, but !Environment.UserInteractive || !Console.IsInputRedirected doesn't seem to trigger. It still asks me to press a key.
Let me know if you need more information.
I'll add a new env var for DW2MC_NO_CONSOLE in the next push later this evening that will force the launcher and mod loader to use only GUI for user interaction.
The reason for not just providing a direct disabling mechanism for the message is to avoid user exploitation.
Sorry for the delay in getting this resolved. Ping me on discord if you could, might speed up testing cycle.
On Thu, Apr 7, 2022, 10:18 AM 0cc4m @.***> wrote:
Thank you for the quick response! The disableIsolation variable gets set by default now, I think, but !Environment.UserInteractive || !Console.IsInputRedirected doesn't seem to trigger. It still asks me to press a key.
Let me know if you need more information.
— Reply to this email directly, view it on GitHub https://github.com/DW2MC/DW2ModLoader/issues/1#issuecomment-1091800810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIC7PYDSYNUBMIII4NFDVSLVD3VCPANCNFSM5RFEIDNA . You are receiving this because you commented.Message ID: @.***>
Thank you! Now I can get past the isolation warning up to the DW2-Splashscreen, but then it crashes within the ModLoader with a System.Net.Http.HttpRequestException. If you find a way to let me know your Discord tag we could try to solve it that way, sure.
Discord link is on https://github.com/DW2MC ; https://discord.gg/2NqHA8eCSm