thomasakarlsen / TruckersMP-Launcher

Unoffical TruckersMP launcher
MIT License
15 stars 9 forks source link

[Wine] System.TypeInitializationException. Program crashes on startup #8

Open lhark opened 7 years ago

lhark commented 7 years ago

Hi, i'm trying to get your launcher working with wine (long story short, the official launcher simply won't work), but it crashes right at the start. Here is the stack trace that wine gave me (I hope it's somewhat standard, i've never touched C# before) :

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'truckersmplauncher.Launcher' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: name
  at System.Reflection.Assembly.GetManifestResourceStream (System.String name) <0x1f93af0 + 0x002cb> in <filename unknown>:0
  at truckersmplauncher.TruckersMPLauncher.<.ctor>b__0_0 (System.Object sender, System.ResolveEventArgs args) <0x1f90188 + 0x0016d> in <filename unknown>:0
  at System.AppDomain.DoAssemblyResolve (System.String name, System.Reflection.Assembly requestingAssembly, Boolean refonly) <0x1f26c38 + 0x001cb> in <filename unknown>:0
  at (wrapper managed-to-native) System.AppDomain:LoadAssembly (System.AppDomain,string,System.Security.Policy.Evidence,bool)
  at System.AppDomain.LoadSatellite (System.Reflection.AssemblyName assemblyRef, Boolean throwOnError) <0x1fc2d78 + 0x0003b> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.AppDomain:LoadSatellite (System.Reflection.AssemblyName,bool)
  at System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) <0x1fc2830 + 0x00157> in <filename unknown>:0
  at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) <0x1fc2128 + 0x0012f> in <filename unknown>:0
  at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) <0x1fc1d00 + 0x000b3> in <filename unknown>:0
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, System.Threading.StackCrawlMark& stackMark) <0x1fc1870 + 0x00343> in <filename
unknown>:0
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) <0x1fc1820 + 0x0003f> in <filename unknown>:0
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture, Boolean wrapUnmanagedMemStream) <0x1fc0ba8 + 0x00229> in <filename unknown>:0
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture) <0x1fc0b70 + 0x00027> in <filename unknown>:0
  at truckersmplauncher.Properties.Resources.get_launcherlogo () <0x1fc0838 + 0x00029> in <filename unknown>:0
  at truckersmplauncher.truckersfm.InitializeComponent () <0x1fb2dc8 + 0x006df> in <filename unknown>:0
  at truckersmplauncher.truckersfm..ctor () <0x1f952e0 + 0x0001b> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) truckersmplauncher.truckersfm:.ctor ()
  at truckersmplauncher.Launcher..cctor () <0x1f95208 + 0x0005b> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at truckersmplauncher.TruckersMPLauncher..ctor () <0x1f2b320 + 0x00213> in <filename unknown>:0
  at truckersmplauncher.Program.Main () <0x1f20f60 + 0x0002f> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'truckersmplauncher.Launcher' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: name
  at System.Reflection.Assembly.GetManifestResourceStream (System.String name) <0x1f93af0 + 0x002cb> in <filename unknown>:0
  at truckersmplauncher.TruckersMPLauncher.<.ctor>b__0_0 (System.Object sender, System.ResolveEventArgs args) <0x1f90188 + 0x0016d> in <filename unknown>:0
  at System.AppDomain.DoAssemblyResolve (System.String name, System.Reflection.Assembly requestingAssembly, Boolean refonly) <0x1f26c38 + 0x001cb> in <filename unknown>:0
  at (wrapper managed-to-native) System.AppDomain:LoadAssembly (System.AppDomain,string,System.Security.Policy.Evidence,bool)
  at System.AppDomain.LoadSatellite (System.Reflection.AssemblyName assemblyRef, Boolean throwOnError) <0x1fc2d78 + 0x0003b> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.AppDomain:LoadSatellite (System.Reflection.AssemblyName,bool)
  at System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) <0x1fc2830 + 0x00157> in <filename unknown>:0
  at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) <0x1fc2128 + 0x0012f> in <filename unknown>:0
  at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) <0x1fc1d00 + 0x000b3> in <filename unknown>:0
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, System.Threading.StackCrawlMark& stackMark) <0x1fc1870 + 0x00343> in <filename
unknown>:0
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) <0x1fc1820 + 0x0003f> in <filename unknown>:0
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture, Boolean wrapUnmanagedMemStream) <0x1fc0ba8 + 0x00229> in <filename unknown>:0
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture) <0x1fc0b70 + 0x00027> in <filename unknown>:0
  at truckersmplauncher.Properties.Resources.get_launcherlogo () <0x1fc0838 + 0x00029> in <filename unknown>:0
  at truckersmplauncher.truckersfm.InitializeComponent () <0x1fb2dc8 + 0x006df> in <filename unknown>:0
  at truckersmplauncher.truckersfm..ctor () <0x1f952e0 + 0x0001b> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) truckersmplauncher.truckersfm:.ctor ()
  at truckersmplauncher.Launcher..cctor () <0x1f95208 + 0x0005b> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at truckersmplauncher.TruckersMPLauncher..ctor () <0x1f2b320 + 0x00213> in <filename unknown>:0
  at truckersmplauncher.Program.Main () <0x1f20f60 + 0x0002f> in <filename unknown>:0

I'm sorry I can't help you more, but as I've said, I know nothing about C# :/

thomasakarlsen commented 7 years ago

Long story short, neither my launcher nor TruckersMP has support for wine.

As for my launcher, wine is missing some functions which my launcher uses during intilazation. I have a couple of DLL's intergrated within the exe of the launcher and some code at the start of it which reads the internal assembiliy and loads those DLL's so the launcher can use them during operation.

The Official TruckersMP Launcher does infact have DLL's it use aswell, but they are not intergrated into their exe which can be why you wont get the same error with it.

The big issue with using wine on my tools for TruckersMP, and the TruckersMP Mod itself is that they are all desgined to run on windows, there are functions which are specific to windows and wont work on any other OS. And yes, wine emulates a fair bit of them, but not enough for proper emulation of my tools, and certainly not the multiplayer mod

Even if you were able to get a launcher working, you are still going to have problems when launching the game. The mod is buildt with windows dependencies and functions specific to windows and its not guaranteed that wine will be able to emulate them all.

lhark commented 7 years ago

To bad :/ Though i'm pretty sure I saw on the forum that the mod worked with wine with the previous launcher, so all hope isn't lost ^^

At the very least do you know which DLLs it's missing ? I already managed to get over one error message by copying Newtonsoft.Json.dll in the same directory, might work for the others too, who knows ?

In any case, thanks for your fast and precise answer.

lhark commented 7 years ago

As a closing note, to any linux user who happens to followthe same steps as i did, i managed to solve the problem... by writing my own launcher : https://github.com/lhark/truckersmp-cli , which is designed to work with wine. By the way, thank you @TheUnknownNO, your code was a great help :)

I however, have one last question for you: how did you fix (if you had to fix it at all) the steam dialog "allow game launch ?" that pops up when you launch the game while steam isn't already running ?

thomasakarlsen commented 7 years ago

As for my launcher it has two DLL's intergrated, as you found out, Newtonsoft.Json.dll is one of them and the other one is called NAudio, which you can find here

As to how I "got rid of" the allow game launch dialog, I cant say for certain it will show that dialog if you try to run the game without having steam open, but by default my launcher starts steam automaticly when you open the launcher, and hopefully the steam logo popping up prompts you to wait until steam gets launched. I've acctually never tested if it starts the game without that prompt if steam is not open. But all in all its up to the way you launch the game, you can see my code for it in the Launcher.cs file

thomasakarlsen commented 6 years ago

Right. I've finally sat down and investigated this issue properly. Progress so far: LauncherOnMint

Next up is redoing some backend so you can set paths for your installs manually ;)